Facebook Interview Question: Given a string, return true i... | Glassdoor

Interview Question

Software Developer Intern Interview

Given a string, return true if it's a palindrome. Only

  alphanumeric characters considered. Do this in one pass through the string.

Interview Answer

1 Answer


boolean isPalindrome(String input) {
    String copy = input;
     for(int i = 0, j= input.length() - 1; j >= 0; --j)
           if (input.charAt(i++) != copy.charAt(j))
                 return false;
     return true;

KSP on Mar 2, 2013

Add Answers or Comments

To comment on this, Sign In or Sign Up.