412 2/23/2016 5:17:00 AM


:

Assumption - Lets say A[1,2,3,...,N] is string stored in array

:

Returns true if string is palindrome otherwise return false

:

A[1,2,3,...,N]

HALF_COUNT=N/2

FOR I= 0 TO HALF_COUNT

IF A[I] != A[HALF_COUNT-I]

RETURN FALSE

END IF

NEXT I

RETURN TRUE

:

public static boolean isPalindrome(String s)

{

int N = s.length();

for (int i = 0; i < N/2; i++)

if (s.charAt(i) != s.charAt(N-1-i))

return false;

return true;

}