Pergunta de entrevista da empresa Meta

check palindrome, print subsets, multiply numbers in string.

Resposta da entrevista

Sigiloso

13 de dez. de 2013

palindrome: #include #include 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")); }