Code Challenge, April 19th 2017
Every two weeks, 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:
Write a function that determines if any given string has all unique characters (i.e. no character in the string is duplicated). If the string has all unique characters, print "
all unique". If the string does not have all unique characters, print "
Scroll down and
reply to this thread with your code to participate! Don't just submit your code, remember to
explain your solution, too!
Don't worry if someone has already posted the solution you had in mind, this should be a fun challenge for you, so why not write it up and post it anyway, or consider doing something for extra credit?
If you'd like to go a step further:
Don’t use any additional data structures.
Make your submission as efficient as possible!
The Winning Entries
See our favorite submissions (and why we picked them) here.
How to participate
Though this challenge has now "ended" in the sense that we have chosen our favorites, you should feel free to post your own response! Just make sure that your code is correctly formatted.
If you do want to try this, why not stretch yourself a bit further and try this challenge in a language that you don't know well, or a language that isn't as well suited to this sort of task as the likes of Python? Or go for a solution that is off-the-wall, a very unusual (yet interesting and artful) way of solving the problem that is likely not maximally efficient? You won't necessarily stand a better chance of "winning" this way, but it will help you to push yourself if you need something more challenging.
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.
* Please don't use any unusual repos or anything that will make it more difficult for your fellow users or Codecademy staff to assess your answer.
* Do you have a code challenge to share with other users? Let us know! Make a new topic with
[Challenge] in the title to open a challenge, maybe we'll even feature it in our next newsletter!