#Code Challenge #12: June 28, 2017
Every week, we feature the type of brain-teasing question that might be asked in a full-stack developer’s job interview at places such as Google and Facebook.
This week’s challenge was reported to have been asked in interviews at Facebook:
###Basic Difficulty
Write a function,
isPermPalindrome
, that will test if a given string is a permutation of a palindrome.
-
Function Name:
isPermPalindrome
-
Input: a
String
consisting only of lowercase letter characters -
Output: a
boolean
,true
if the string is a permutation of a palindrome andfalse
if the string is not a permutation of a palindrome -
Examples:
-
isPermPalindrome("kayak") => true
-
isPermPalindrome("yakak") => true
-
Permutations are all possible arrangements of a collection of things, where the order is important.
-
From Merriam Webster, a palindrome is a “word, verse, or sentence (such as “Able was I ere I saw Elba”) or a number (such as 1881) that reads the same backward or forward.” Read more about palindromes here or see some interesting examples here.
#####Find out more about basic challenges.
###Intermediate difficulty
As above, but
isPermPalindrome
should now be able to account for punctuation, spaces, and capitalization in the input string.
- Your input string may now include spaces, numbers, punctuation, and capitalization, but in assessing whether the string is a palindrome or not, spaces, punctuation, and capitalization does not matter. For example, akyKa is a permutation of Kayak, but we don’t care that there is one upper case
K
and one lower casek
in Kayak – this is still a palindrome. - Example:
isPermPalindrome("Science Bros.") => false
#####Find out more about intermediate challenges.
###Hard Difficulty
Write
isPermPalindrome
as efficiently as possible.
#####Find out more about hard challenges and Big O
Reply
to this thread with a link to your code on repl.it and paste your properly formatted code to participate! Don’t just submit your code, remember to explain
your solution, too! If you want to be considered as the winner, your function must
have the correct name
and provide output in the format specified
above, you also need to abide by our other simple rules.
As always solutions using imports to do all the heavy lifting such as itertools
will not be considered for the winner.
The fine print:
Click the links to find out more about:
- the rules & how to participate in challenges
- how challenges are used as job interview questions
- why Codecademy runs challenges (and why they are formatted this way)
- more details about the challenges and why we think they are useful.
- find previous challenges (and see the past winners) in our Challenge Index