BestAns

 avatar
unknown
java
2 years ago
342 B
5
Indexable
    public static boolean isPalindrome(String str) {
        // Remove spaces and punctuation, and convert to lowercase
        String temp  = str.replaceAll("[^a-zA-Z]", "").toLowerCase();
        return IntStream.range(0, temp.length() / 2)
                .noneMatch(i -> temp.charAt(i) != temp.charAt(temp.length() - i - 1));

    }
Editor is loading...