#Code Challenge, April 26th 2017
Every week, we feature the type of brain-teasing question that might be asked in a full-stack developer’s job interview, similar to the FizzBuzz Challenge often used at places like Facebook and Google.
For this week’s challenge, inspired by a question reported to have been asked in developer job interviews at Microsoft:
Write a function in your favorite programming language that will accept any two strings as parameters and return “
1
” if they are anagrams and “0
” if they are not.
For simplicity’s sake, focus only on strings composed from uppercase letters (in hex ASCII - from 41
(A) to 5A
(Z)) and space characters.
####Scroll down and reply
to this thread with your code to participate! Don’t just submit your code, remember to explain
your solution, too! Please link to your code on a site like repl.it to make assessing your entry easier (see below).
##Extra Credit
####Intermediate Difficulty
If you’d like to go a step further:
Make sure that your answer has no more than
O(n + m)
time complexity, wheren
is the length of the first string andm
of the second.
Make your submission as efficient as possible! You can presume that the hypothetical interviewer in this case is looking for the most direct approach that does not involve len(n)!
permutations.
Learn more about Big O notation and time complexity here and here. There’s also an old (and thus unsupported) Codecademy course on Big O, if you prefer.
##The Winners
For the “best entries,” see here!
Though it is now too late for any more submissions to be considered as a “best entry,” we encourage you to submit further responses anyway! It is our hope not only that you’ll benefit from the experience in testing your skills or preparing for interviews, and your posting your answer here will build up a library of content that will help others to learn too.
###How to participate
-
Use any language taught on Codecademy (Python, Java, Ruby, JavaScript, PHP, etc.)
-
Please include a link to your code running on service like repl.it, CodePen, JSFiddle, or our very own CodeBits so that your fellow students can learn from your submission easier and faster - if we have hundreds of submissions, we may not have time to assess entries that do not have links in this manner
-
If you want to post your code directly, please make sure that it is correctly formatted!
Happy coding!
The fine print:
- Remember, the point of code challenges like these is to test and stretch yourself with an unusual problem, so don’t be dissuaded if you find it difficult or don’t know where to start! Start with Googling, but see if you can find out how to think about the problem and what tools you need to solve it, but don’t just go looking for the solution itself. This way, it’ll be a better learning exercise for you - developers can’t always find and copy “the right answer” online, which is why questions like these are used in developer job interviews! Interviewers want to be able to see how you think through problems and not just whether or not you can solve them.
- If you are interested in “winning” the code challenge, please don’t use any unusual repos or anything that will make it difficult for us or your fellow users to assess your answer quickly.
- Do you have a code challenge to share with other users? Issue it! Make a new topic with
[Challenge]
in the title to open a challenge, maybe we’ll even feature it in our next newsletter!