Cracking The Coding Interview: 12 Things You Need To Know
Cracking the coding interview is the holy grail of many programmers and software developers, but is cracking the coding interview really possible?
Nothing, I mean nothing, terrifies more software engineers than the dreaded coding interview.
Sure, Gayle McDowell, wrote an excellent book that is actually called āCracking the Coding Interview,ā but is it actually possible?
Yes, but I donāt think memorizing a bunch of programming questions is all you need to do to be successful at cracking the coding interview.
Here are 12 things you need to know if you really want to stand a chance at cracking the coding interview:
#1 How to code algorithms (really cracking the coding interview)
Itās a coding interviewāduh. If you want a chance at cracking the coding interview, you have to be able to code.
Iām often surprised how many software engineers donāt realize this simple detail.
Now, writing regular day-to-day code is a bit different than writing the kind of code to implement the coding interview problems you are likely to getāwhich mostly consist of algorithms.
You may get questions like: Write an algorithm to find an element in a linked list and move that element to the end of the list.
Or you might get a question that basically asks the same thing, but disguises it in a clever word problem involving robots on an assembly line. Regardless, you need to know how to program algorithms.
But, are you born knowing how to program algorithms?
Perhaps you were, but I wasnāt. Instead, I had to practice.
Sure, you may have learned a little bit about data structures and how to implement different kinds of algorithms in collegeāand you may even remember a little bit of itābut, you probably didnāt do a whole lot of practice at writing bubble sort algorithms or searching binary trees.
But, I wouldnāt give you a problem and get you all nervous without giving you a solution, would I?
No, I wouldnāt. Well, I might, but I wouldnāt be that obvious about it.
Anyway, here are some good resources to practice coding algorithms.
- Top Coder ā I wrote a blog post about how to use Top Coder to practice programming problems. (Itās an older post of mine, so cut me some slack.)
- Programming Pearls (2nd Edition)Ā ā Classic book by Jon Bentley. (I even remembered his name without having to look it up.) Chock-full of hard problems that you have to write code to solve. Great practice and a lot of fun. Iām serious. If you donāt like solving these problems, what are you doing being a programmer.
- Cracking the Coding Interview: 150 Programming Questions and SolutionsĀ ā Even though Gayleās book is beating out mine on Amazon, I still have to recommend it, because it really is good and does have a lot of good problems to practice and learn from. But, make sure you donāt just memorize those problems. Work them out on your own, so you can get good at doing it. Yes, Iām talking to you!
- My Pluralsight Course, Preparing For a Job Interview ā See, I didnāt even put my course first. In this course, I basically walk you through solving a few of these algorithm problems and do something that I havenāt seen anywhere else: I give you an actual process for how to learn how to solve these types of problems yourself. I also cover a bunch of other job interview tips and questions.
- Project Euler ā If I donāt include this one, Iāll get a bunch of emails from people whining about how I didnāt include project Euler. So, there, here it is. (That is an awkward sentence.) Anyway, this is actually a really good resource. Plus, there are lots of examples of how all kinds of people solved these problems in all kinds of wacky ways, doing all kinds of psychedelic drugs.
Ok, enough about that one. Iāve got, like, 11 more to cover.
Just make sure you get to the point where you feel comfortable writing some code to sort an array containing the color of hair on a cat into three lists in order of hair length, or something like that.
#2 Write code WITHOUT tools
Yes, Visual Studio with Resharper basically makes you a demi-god.
Yes, I know you Java people, that IntelliJ and Eclipse do the same things without any plugins.
Yes, I know that you Node people do it all without an IDE and can do it all with just your Sublime Text. (Oh, and about 50 plugins that essentially make it an IDE, but we wonāt talk about that. Shhhh.)
Anyway, IDEs and bare-bone-text-editors-with-50-million-plugins, are extremely powerful, but when you walk into a coding interview, you might just get handed a piece of chalk.
(So, that means you Linux guys and gals with your VM and Emacs will need to take heedĀ as well.)
Iām not suggesting that you write your everyday production code on a chalkboard. But, you might want to at least practice sketching out some code by hand without auto-complete or typing some code into notepad if you really want to be cracking the coding interview. Do you feel me?
#3 Have a portfolio
You know what proves you can code more than anything else?
Code.
Yes, I know. It seems like far too easy of an answer.
But, if I am wondering if you can write code and I see your codeāor something you built with codeāthat kinda proves it for me.
Yup, this guy either randomly hit keys on his keyboard until an app magically popped out, or he can code.
So, it only makes sense that someone who has hopes of cracking the coding interview would have a portfolio full of code and applications they built using code to show any prospective interviewer.
What? Whatās that you say? How do you get a portfolio?
Iām glad you asked. Here are two easy ways:
- Build mobile apps and have the source code ready to show. I always harp on the idea that new developers, especially, should take advantage of how easy it is to build a complete mobile application all by themselves. Seriously, go learn Android or iOS, and build at least one or two simple mobile applications that you can show off. Itās nice to be able to point to some app you built that is in an app store and then show them the code you wrote to make it.
- Get GitHubbing. GitHub is a wonderful place where you can put open-source code you are working on for the world to see. You can also contribute to open-source projects, which will give an excellent example of the kind of code you write and prove that you can work on a large-scale application. GitHub is an excellent portfolio for any coder.
You can also build web apps or VB6 apps to showcase your talents, but Iām going to stick with my top two choices. (Mmm⦠VB6. Now that is how you really get to cracking the coding interview. Throw down some printed out VB6 code on their desk and shout āwa-bam son!ā)
#4 Think out loud
Interviewers are not mind-readers. They donāt know what you are thinking when you are scratching your head trying to figure out how to insert a new node into a linked list.
Sure, you might not get the interview question right, but you can at least let the interviewer know you are on the right track or that you arenāt completely stupid, by thinking out loud while you are trying to solve the problem.
Trust me, Iāve been on the other end of the interview table enough times to know that there is nothing worse than someone frantically sweating, soaking through their shirt, while crushing the whiteboard marker in their hand and frantically erasing things in complete silence.
Itās awkward. It makes me uncomfortable. It makes you uncomfortable. It makes the little duck I have sitting in my office that I tell all my problems to uncomfortable (and heās got a high tolerance for this shit.)
So, just talk. When you are trying to solve a problem, talk through it.
You do get bonus points for thinking about a problem the right way and showing your problem solving skillsāeven if you donāt get the answer right.
#5 Donāt argue, blame or make excuses
I really shouldnāt have to say this one⦠but, sadly I do.
Seriously, as Vince Vaughn would say:
āOur little babyās all grows up. You know what? ⦠Our little babyās all grows up. ⦠Iām not even hungry, I couldnāt touch it. ⦠Our little boy is all grows up tonight. You know what big boy? Youāre grown up. Youāre grown up! Yeaaaheyha! Dig that! Is this a f*****ā production for ya? Cuz youāre growns up and youāre growns up and youāre growns up! Iām the asshole in the bar place is that right? Iām the asshole? Iām outta here. Iām not eatinā anything. I wouldnāt eat here, I would never eat here anyway.ā
-Vince Vaughn, Swingers (1996)
Ok, I didnāt really need to put that long quote in there, but Iāve been waiting to use it, but I think you get the point.
You are a big boyāor girl. Donāt be a f****** baby!
Seriously. If you donāt know the answer to the interview question, donāt be all like āYOU DIDNāT ASK ME IT RIGHT!ā
Donāt blame your computer science professor for not using deodorant, so you couldnāt pay attention in class.
Donāt make excuses like you arenāt feeling well or your mommy forgot to pack your lunch today.
Man up, or put on your big girl pantiesāwhatever the case may be. (No judgments.)
Take responsibility for your own actions and if you donāt know the answer, simple, say āI donāt know the answer.ā
Or even better, say āI donāt know the answer but Iāll find out. You s****brain a**hole!ā
Ah! Just seeing if you are still paying attention.
#6 Donāt give up
Iām so tempted to drop another Vince Vaughn quote on you right now, but I am going to resist the urge and just tell you to not throw in the towel too early.
Really, at the first sign of trouble, donāt just throw your hands up in the air and give up.
Try a little. Try a little more. Make them tear you from the blackboard kicking and screaming while you swear that all you need to do is just swap this one variable and your algorithm will work. (Ok, donāt do that, but I think you get my point.)
F*** it, youāre getting Vince Vaughn after all:
Trent: You know what you are? Youāre like a big bear with claws and with fangsā¦
Sue: ā¦big f****ing teeth, man.
Trent: Yeah⦠big f****inā teeth on yaā. And sheās just like this little bunny, whoās just kinda cowering in the corner.
Sue: Shivering.
Trent: Yeah, man just kinda⦠you know, you got these claws and youāre staring at these claws and your thinking to yourself, and with these claws youāre thinking, āHow am I supposed to kill this bunny, how am I supposed to kill this bunny?ā
Sue: And youāre poking at it, youāre poking at itā¦
Trent: Yeah, youāre not hurting it. Youāre just kinda gently batting the bunny around, you know what I mean? And the bunnyās scared Mike, the bunnyās scared of you, shivering.
Sue: And you got these f****ing claws and these fangsā¦
Trent: And you got these f****ing claws and these fangs, man! And youāre looking at your claws and youāre looking at your fangs. And youāre thinking to yourself, you donāt know what to do, man. āI donāt know how to kill the bunny.ā With this you donāt know how to kill the bunny, do you know what I mean?
Sue: Youāre like a big bear, man.
Mike: So youāre not just like f****ing with me?
Trent: No Iām not f****ing with you.
Sue: Honestly, man.
Ok, so it wasnāt even completely relevant, but just pretend like it was, ok?
Anyway, an interviewer will respect you a lot more if you try hard. No one wants a coworker that whines about how hard something is and gives up and browses Facebook all day. You have claws, use them. (See, what I did there?)
#7 Test your code
Aw yeah! My code is off the hook. I donāt need to test it.
Yes, I know your code is perfect the second you write it.
Yes, I know that angels sing and the clouds part when you place the last curly brace on the algorithm you implemented.
But,Ā you gotta make it look like you at least gave it some effort.
You donāt want your interviewer to reject you simply because you would create a completely unobtainable standard by which all mere mortal programmers would be judged, once you joined the company.
So, pretend like your code might be capable of having errors and test through it before you tell the interviewer that you are done.
Really, I canāt believe how many software engineers, who would normally test every line of code they write, completely forget to do this in an interview or think itās not important.
Write a unit test to test it if you can, but if you canāt, at least paper test it. (That means walk through the code with possible inputs, line-by-line.)
#8 Name things clearly
Another thing that seems to go out the window during the coding interview.
If you want a chance at cracking the coding interview, you need to come up with better names than ābanana.ā
You should never name your variables after fruitā¦
Yes, someone I worked withāI wonāt name namesāonce named all the variables in their C++ application after names of fruits.
It was exactly as amusing as it sounds.
If you are in a coding interview and you write code with one-letter variable namesālike I so often see in coding interviewsāthe interviewer is going to assume that is how you normally write the code that you put into production in real-world applications.
I know that you really name your variables wonderfully.
You know you do.
But, guess what? The interviewer doesnāt.
It takes you like 2 extra seconds to think of and write out a clear and meaningful variable name, so do it.
Iām serious. Do not make me pull out another irreverent Vince Vaughn quote. Iāve already got Wedding Crashers loaded up on IMDB.com and I am ready to go.
#9 Ask for feedback
You write perfect code. Weāve already established that.
Your variable names are perfect and make angels cry. You donāt have to try and convince me, I know it.
But, even with all that perfection floating around, it doesnāt hurt to ask the interviewer their opinion on your code and your solution to the problem.
Yes, I know they are going to say some irrelevant bull-crap, but remember what I said about making them feel important? You know that unobtainable standard of perfection that you donāt want to project?
Ask them for feedback. Especially if you donāt know the answer to a problem and theyāve timed you out.
Show that you are interested in learning and that you donāt just want to get the answer right, but you want to understand it.
I guarantee it wonāt make you look stupid.
#10 Donāt rush
Itās not a race.
Cracking the coding interview isnāt about being super fast and not giving a crapĀ if you get everything wrong.
Itās about being thoughtful, analytical, careful and accurate. (Dammit Chrome, analytical is too a word. Iām leaving it. You can put that little squiggly under the word all you want!)
Anyway, here is the deal: No one is going to be super impressed if you whip out code super fast, but do it carelesslyāeven if your code is flawless.
I know it seems super impressive. I know you see presenters at conferences do itābut, let me let you in on a little secret there, they use a macro.
But, the big problem is, it looks careless. It looks like you just donāt care and you are all about showing off instead of writing good code.
I donāt know about you, but I want to work with someone who is deliberate and takes their time to make sure things are right, not some hot-shot code-jockey that slams out code and lets me deal with the bugs.
So, donāt be that guy.
Be the guy who takes his time, tests his code and makes sure it works, before he throws it over to the interviewer and says heās done.
Be that guy. I like that guy.
#11 Practice mock interviews and take notes
Again, another basic, duh, thing that seems so obvious, yet so many programmers fail to do.
Your code is abysmal
Before going into a coding interview, practice being interviewed. You can even set up real interviews, but I like to have interviews with my imaginary friends or long-dead historical figures.
One time Abraham Lincoln told me to write an algorithm to reverse all the words in a string while singing the national anthem.
Benjamin Franklin often extols the role that virtues play in the proper naming of variables when I mock interview with him.
In all seriousness though, go out and practice some mock interviews with your friends or your family. Get comfortable answering the questions an interviewer is likely to ask you.
And, when you do go to an actual interview, regardless of the outcome, take notes afterward, when the interview is still fresh in your mind.
I constantly hear developers whining about how they keep getting rejected, interview after interview.
Well, guess what they say when I ask them if they did any mock interviews?
No.
And, when I ask about taking notes, so theyāll know what they need to work on next time and improve?
Nada.
Do you know what whining without doing anything about your problem is?
Itās annoying!
Stop it!
#12 Ask questions
Alright, weāve reached the end.
Iām tired of writing, you are tired of reading what I am writing, but Iāve got one more point and then you can load blast this blog post all over your Twitter feed, submit it to Hacker News and buy my book.
My last tip, is one that isnāt so obvious, because a coding interview doesnāt really feel like a real work environment, but once you make the connection, Iām sure youāll see how important it is.
Let me give you a bit of an example that will illustrate what Iām about to tell you.
Suppose you are at your job gathering some requirements from a customer about what you are supposed to build. Letās pretend like they are sane and youāre sane. Weāre all sane in this example. (Even though we know this is far from the truth in real life.)
Smacks your hand with a ruler
No! No, you donāt.
What you do is, you ask a bunch of questions.
How tall do you want the box?
What is supposed to happen when the customer enters their name?
Do we need just the last name and the first name or do we need the middle name and their grandmaās name as well?
What color underwear are you wearing?
You ask a lot of questions. You drill deeper to find out more information.
So, why donāt you do that in an interview.
Donāt just start coding the solution to a problem. Even if you think you understand it.
Ask the interviewer some questions to confirm.
The point isnāt to run off and code the right answer, the point is to simulate how youād behave in a real-world environment.
Just like naming things, if you donāt ask clarifying questions about your assignment in a coding interview, the interviewer is likely to assume that you wouldnāt ask questions in a real-world situation either.
So, take your time, ask questionsāmake sure you understand what kind of code you are supposed to write, before you write it.
#Bonus: Want to avoid a lot of this and get the job anyway?
Look, hereās the deal. All of this is useful for cracking the coding interview.
I sincerely hope it helps you, but Iād be doing you a big disservice if I gave you all these tips, slapped you on the back and said, āgood luck kid.ā Iāll tell you why.
The reason is because while cracking the coding interview can be an important part of landing your dream job, itās not the only component, nor is it the most important.
In factāand you are going to find this hard to believeāyou can sometimes⦠sometimes⦠avoid the coding interview completely if you have a good grasp of the kind of Soft Skills that can let you slip in the back door.
Many times in my career I was offered a job, not because I was a crackerjack coder (that means good, I looked it up), but rather because I had figured out ways to build connections with interviewers at the company ahead of time and had built up a reputation online that allowed me to sometimes even bypass the interview completely.
Anyway, I wrote a book called āSoft Skills: The Software Developerās Life Manual,ā that is full of all kinds of advice on how to improve your career, get a better job, become more productive and even improve your health and finances. And itās all written specifically for software engineers, programmers, software developers, whatever you want to call yourself.
Look, itās way better than Cracking the Coding Interview, (sorry Gayle), just check out the reviews on Amazon.
Ok, thatās all I have to sayā¦
Peace!
| Reference: | Cracking The Coding Interview: 12 Things You Need To Know from our NCG partner John Sonmez at the Making the Complex Simple blog. |


