BestAns

mail@pastecode.io avatar
unknown
java
a year ago
342 B
2
Indexable
Never
    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));

    }