Google interview question

Palindrome String problem

Interview Answers

Anonymous

4 Jul 2015

Assumed in a NSString category: ------------- - (BOOL)isPalindrome { NSUInteger i = 0, o = self.length; while (i < o) { if ([self characterAtIndex:i] != [self characterAtIndex:o]) { return NO; } ++i; --o; } return YES; }

1

Anonymous

8 Feb 2017

Swift func isPalindrone(testString: String) -> Bool { var testString = testString while testString.characters.count > 1 { if testString.characters.popFirst() != testString.characters.popLast() { return false } } return true }

1