Sollicitatievraag bij Google

Palindrome String problem

Antwoorden op sollicitatievragen

Anoniem

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

Anoniem

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