Cracking that coding interview

8 minute read

After a series of interviews, I received a full time offer from Microsoft a couple of months ago. The interviews turned out to be a fun exercise - given how worried I was about screwing up. Now I want to talk all about the “hardship” that lead up to the offer. This will be a highly opinionated post depicting what worked for me.

The Boilerplate

Any sensible post about job interviews should discuss these boilerplate topics like making a killer CV, applying through references, quantifying your contributions in a previous job or project, and on it goes. We might as well get this over with, because frankly, they are not wrong for most part. This may be boilerplate, but is nevertheless important! I myself followed most of it as discussed in Cracking the Coding Interview - from here on out referred as CTCI. Instead of paraphrasing ideas from the book, I strongly advice that you go over it once and then again before each interview - been there, done that and helped me a lot! I can’t stress this enough but, just so you know, the last thing I did before most of my interviews was go over the bookmarks I added in CTCI. Quantifying your contributions is good thing and applying through references definitely puts you in a better position than otherwise. If you are interested, here is the version of my CV that I used while applying to Microsoft.

Setting Goals

More often than not, it helps if you have in mind at least a vague idea about the jobs or companies you are aiming for. When I started my job search, I was fairly proficient in Android, Java, Angular and Python development - I literally had enough convincing work to back up my expertise in any field I choose among these. Okay bragging aside, I do have a point, that I didn’t go about searching for jobs in all of these areas. That would have diluted my search efforts in any single domain. Instead, I made a pick or two based on where I can sell myself better and also what interests me more - I went with Android and Java. Since I stopped trying to be jack of many trades, it helped me focus. I started solving any new coding challenge in Java (before, I was doing them in Python - for reasons). This helped me get even more familiar with Java - particularly at writing solutions for typical coding challenges. After a point, you will start thinking in terms of pseudo-code and core algorithm, rather than having a corner of your brain always wondering how you would go about implementing it in Java / xyz programming language. We need help from all the neurones we can get if we aim to impress!

While it’s not strictly necessary, it might also help if you have a set of companies you are aiming for. I had the big 4 - Amazon, Facebook, Google, and Microsoft, on my list. Share your list with a few friends and ask them for an honest feedback because that will help you figure out if, you are being too ambitious, or selling yourself short. The big tech companies usually stress on Computer Science fundamentals so, it doesn’t really matter which names are on your list. However, if you are going after very specialised firms, this could help you identify where you should devote your time - a particular tool or tech stack or design concept, you get the point.

Preparation

This goes without saying but I’m going to say it anyway: Practice makes you perfect! There are plethora of sources on and off the web that will help you reach perfection but as I clarified at the very onset, this post is about what worked for me and so, it continues be - opinionated. I solved every question from CTCI the way they are meant to be - writing code on a white paper and typing it back on a computer for verification. This helped me pickup some otherwise trivial details about writing code with no assistance from auto-complete and such. Also, this way you won’t discover your particular lack of skill to do so during the actual interview - we have enough surprises waiting for us as is, so don’t leave things to chance. As far as online prep goes, I solved questions from Google Codejam, Codeforces, Hackerrank, and Leetcode. Among other things, each of them have subtile differences in the solution submission format and I think that’s a big factor in picking the right one for you. For reasons I will now discuss, I preferred Leetcode. Google Codejam was an easy elimination because the problems level is much higher than what you would come across in a typical interview and I didn’t want to kill my confidence. While hackerrank, Codeforces and Leetcode all offered problems of various levels, Leetcode’s solution submission format kept track of invalid submissions and that’s a huge deal! Since Leetcode keeps track of invalid solutions - timeouts, failing test cases, and runtime errors, I was forced to run my solutions in mind before submission - exactly what you will be doing during the interview! And when the submission did fail, you get to see the failing test case - this way I can deduce quickly where I went wrong. Most other sites doesn’t reveal the failing test case and thus making you spend more time to figure it out yourself without any clue what could have gone wrong. The latter, hidden test cases, of course has it’s own advantages and I myself emulated this with Leetcode by choosing not to look at the failing input until I’m exhausted enough. Long story short, I found Leetcode as the best fit from a coding interview preparation point of view. Also, since Leetcode seems to primarily focus on questions that already appeared in interviews, there’s a chance you might come across them during your actual interview - I had one such question during my Microsoft interview and I told them so - yeah, be honest, could earn you some brownie points at best. Here is a subset of problems I solved during my preparation stage.

Interview

The big day - everything you have been preparing for, is here! It’s completely natural to be nervous. Personally, I used some ideas from Originals: How Non-Conformists Move the World, about overcoming anxiety. It goes something like this: when you are nervous, you have a positive surge in adrenaline. A typical response from most people in such situations is to calm themselves down. Instead, you could use these spikes to your advantage by speaking up about your enthusiasm for the job or turn it into excitement - in nerdish, use the force! Typically there are multiple rounds of interviews and it gets progressively easier to overcome your fear or nervousness. The good news is companies also want to see your best work so, they try to make you comfortable at the start of each interview - this involves brief introductions from both sides and some small talk. If you are still feeling nervous, this is great time to loosen up a little. In total I had 7 rounds of interviews with Microsoft (2 telephonic, 4 onsite and then 1 more telephonic) and almost all of them had small talk - the time share got progressively shorter, but this helped me a ton to relax at the start of each round! Small talk involves discussing about your past projects, jobs, hobbies and bunch of other things on your CV - if you prepared well enough, it wouldn’t need much thought to come up with answers. Be honest about what you know and don’t. Ask for clarifications when something is ambiguous and state your assumptions before using them. Again, this is all in CTCI but I will repeat to stress the importance - think out loud, come up with at least one positive and negative example to verify that you understood the question right, start with a working solution (even the one with worst time or space complexity is fine) and then improvise on it - lot of incredible things happened through incrementalism. Towards the end, there comes a time for you to ask questions so, make a list and ask some genuine, good questions because this counts too!

Offer or Not

You are smart enough to know what to do when you receive an offer - act like you have been through anything and everything, and probably write another blog post such as this. Now let’s talk about the unpleasant alternative. Rejection isn’t a bad thing in itself but, not analysing why that happened is definitely one of the worst things you could do about it! As the popular saying goes, “Learn from your mistakes”. I’m not the one to keep count but I was rejected by 360T, Optiver, Bunq, and a few more. And despite multiple attempts, I couldn’t even get an interview at Facebook, Zalando, and there goes another list. Okay, I kept count! And just so you know, it’s not always you! Sometimes companies have a specific skill set they are looking for and no one can know it all! Just check if the skill they were looking for is something you want to explore in future, and if so, do something about it. If not, just move along to the next one. Remember, you have to get it right just once (at the least). There’s plenty of fish in the sea and going by the numbers, the odds are in your favor, stay strong and it will happen! If you are lucky enough to have multiple offers, go back to CTCI for some quality advice on that front.

Credits

You have reached the end of our pep talk. I would like to thank all my friends and family, who supported me during this arduous process - for keeping me motivated, expressing your belief in me more than I did myself, and last but not least, helping me draft and proof-read those “Letters of Motivation” - writing these was definitely the most unpleasent part. In particular, Sabareesh, Sampath, Uday, and Sanath, couldn’t have done this without you!

If you made it this far without skimming over, you must be serious! - that’s a great sign, keep it going! Good luck :+1:

Comments