Facebook
4.6 of 5 634 reviews
www.facebook.com Menlo Park, CA 5000+ Employees

Facebook Software Engineer Intern Interview Question (student candidate)

I interviewed in Menlo Park, CA and was asked:
"check palindrome, print subsets, multiply numbers in string."
Add Tags [?]
Answer Flag Question

Part of a Software Engineer Intern Interview Review - one of 998 Facebook Interview Reviews

Answers & Comments

0
of 0
votes
palindrome:

#include <string>
#include <cassert>

bool checkPalyndrome(const std::string& word) {
  if (word.size() <= 1) {
    return true;
  }
  if (word[0] != word[word.size() - 1]) {
    return false;
  }
  return checkPalyndrome(word.substr(1, word.size() - 2));
}

int main() {
  assert(checkPalyndrome(""));
  assert(checkPalyndrome("aba"));
  assert(!checkPalyndrome("abc"));
  assert(!checkPalyndrome("ab"));
  assert(checkPalyndrome("aa"));
}
- Anonymous on Dec 12, 2013 Flag Response

To comment on this question, Sign In with Facebook or Sign Up


Tags are like keywords that help categorize interview questions that have something in common.

Glassdoor is your free inside look at Facebook interview questions and advice. All interview reviews posted anonymously by Facebook employees and interview candidates.