Frage im Vorstellungsgespräch bei Google

Write a function to determain if a string is Palindrome?

Antworten zu Vorstellungsgespräch

Anonym

18. März 2015

use two pointer left and right in a while loop. check whether char at left equals to right. if yes, left++ and right--, if not, return false.

1

Anonym

20. Sept. 2015

public static boolean isPalindrome(String text, int start, int end){ if (text == null) { return false; } if (start >= end) { return true; } if (text.charAt(start) != text.charAt(end)) { return false; } return isPalindrome(text,start+1,end-1); }