employer cover photo
employer logo
employer logo

GREE International Entertainment

Essa empresa é sua?

Pergunta de entrevista da empresa GREE International Entertainment

Write code to detect if a string is a palindrome (i.e. a sentence that may be read the same way in either direction).

Resposta da entrevista

Sigiloso

31 de out. de 2012

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; }