Write code to detect if a string is a palindrome (i.e. a sentence that may be read the same way in either direction).
Anónimo
BOOL isPalindrome( NSString * sentence ) { NSUInteger index = 0; NSUInteger length = [sentence length]; while( index < floor( length / 2)) { unichar leftChar = [sentence charAtIndex: index]; unichar rightChar = [sentence charAtIndex: length - index]; if(leftChar != rightChar) return NO; index++; } return YES; }