loading...

re: Reverse a Word. VIEW POST

FULL DISCUSSION
 

very , very small optimization :p

public static boolean isPalindrome(String input)
{
    char[] charArray = input.toCharArray();
    int cursor = 0;
    int max = input.length() - 1;

    while(cursor <= max && charArray[cursor] == charArray[max-cursor])
    {
        cursor++;
    }
    return cursor > max; 
}

if by any chance you can benchmark the 2 versions : me very glad ;)

Code of Conduct Report abuse