As my first blog post, I thought I should take some time (and space!) to elaborate on what I am attempting here. Since I have decided to go with a technical theme for this blog, I thought of going back to the basics and the first steps. And thats what brought me to start a section dedicated to interview questions. In my experience, practicing interview questions has been a great way to consolidate the basics and learning some “cool tricks”. They are a fun way to challenge oneself. Well they don’t seem that much fun when faced with in an interview 😛 But anyway, there is a point in every software developer’s life when they have to go through the “painful” process of interview preparation. This is one small attempt to ease the process to some extent.
There are several books, blogs and websites available which help you prepare for a technical interview. I have read and followed a few of them and they have some really great advice and good set of problems. To name a few:
Books:
Websites:
3) Career Cup
4) Glassdoor
Now time for some advice! The major lessons that I have learnt while preparing for technical interviews are:
1) Learn to think: This should essentially be done when in undergrad/grad school, but its never too late. While practicing the interview questions, never jump to see the solution. No matter how frustrating it gets or how much ever you are pressed for time, do not see the solution unless you have given your honest effort in solving the problem. Practicing as many problems as you can helps but there is a very important thing to understand here – practice does NOT mean “memorize”! Never attempt to memorize the solution to a problem. That won’t help much. Always try to think through it. So practicing a large number of problems alone without actually thinking, is not the key to crack the interviews. Practicing how to think through a problem is. Developing skills and an understanding to break down a problem and attempting to solve it is more essential and beneficial than to memorize handful of “tricks”.
2) Revisit the undergrad classes: If you sighed with relief thinking that once you are done with your Algorithms and Data Structures undergrad classes, you won’t have to face them again, then it gives me an evil pleasure to tell you that you are wrong 🙂 Algorithms and Data Structures will come and haunt you more often than you would think! So better be friends with them to avoid scary surprises. Other than Algorithms and Data Structures, there are many more fundamental courses that you should be comfortable with. Here is a really helpful blog post by Steve Yegge on what knowledge and skills are expected of a candidate. This post talks in terms of phone interviews, but the topics listed are pretty much what any Computer Science grad should be aware of.
3) Practice on paper or white board: And don’t even begin with an IDE! Writing code on paper/whiteboard is altogether a different ballgame than coding with a compiler or IDE. You tend to make lot more mistakes on paper and miss out on those corner cases. Once you have designed and coded your function, run some test cases by hand. You can catch some bugs during this process. Type in your solution into the IDE only when you think its the final solution. Once you run your function, make note of the errors that you made. Then learn from the mistakes. Always think about the test cases that can fail your function. Think in terms of time and space complexity, attempt to find some more bugs and try to improve the efficiency of the code.
4) Start Simple: After you read the problem statement, think in terms of how a human would solve it. For example, to sort an array of numbers, how would you do it by hand? Forget about the myriad types of sorting algorithms you would have studied. Start simple. Develop an algorithm for how you would sort. Once you have polished the pseudo-code, now think in terms of time and space complexity for your solution. Think about all the various ways you can improve it. Would using a different data structure help? Jumping into finding an efficient solution before devising a working one often leads to many changes being made to the solution and fogs the clarity in thinking.
5) Be confident: Cliche but essential. So you couldn’t think through a problem that seemed somewhat simple. And it was really simple when you finally gave up and browsed through the solution. And this is happening after you had invested a good amount of time in practice. Don’t worry! These are the times when you need to feel confident and remain focussed without getting frustrated. Its hard but its necessary. Revise the topic that you fumbled in. Practice couple more similar problems and make sure this time you get it. Then without letting this shake your confidence, move on.
These were the important lessons that I learnt while preparing for interviews. I hope this guidance helps.