The Coding Interview: A Preparation Guide

Are you feeling a little nervous because you have a coding interview coming up?

I feel you!

You are definitely not alone.

Every person experiences some level of nervousness before big defining moments in their life.

Especially if this is an interview for your first job then the stakes are pretty high.

This coding interview is literally the only thing standing between you and making a six-figure income.

I have been interviewed many times and I remember being a little nervous before every single interview.

Also now that I am on the other side of the table interviewing candidates, most of the exceptional candidates I have interviewed showed some degree of nervousness as well.

You can’t completely eliminate being nervous but you can absolutely reduce your level of nervousness.

This is critical because if your level of anxiety is extremely high then you might ruin your chances of getting hired even if you are genuinely competent.

To get your anxiety under control you need to know what to expect and prepare very well for it.

Preparation is key.

And this is exactly what this article is about.

In this article, I am going to share with you my personal experience both as an interviewee and as an interviewer.

I will teach you how to get a coding interview in the first place, prepare very well for it, and eventually get hired and kickstart your career.

Before you proceed, I want you to know that all the information in this article is based on my experience working in the USA.

If your job is not in the USA, then the information in this article might or might not apply to you.

Alright, let’s get started.

Before you prepare for your coding interview, you need to get one first.

But how?

First: How to get an Interview?

The challenge of getting an interview in a big company is that you will be competing with a lot of other candidates.

Even if you are an exceptional software engineer, it might not be very easy to just get an interview.

The reason is quite simple.

Based solely on your resume, it is the job of the recruiter to accurately and correctly assess your skills, intellect, and how fit you are to work for the company just by quickly glancing through your resume.

Given the sheer number of candidates, you only have a few minutes to impress the recruiter and stand out among your peers.

This is not easy and sometimes unfair but it is what it is.

Let me tell you how I got my first software engineering internship.

A side note about me, my bachelor’s and Master’s degrees were not in Computer Science.

They were in Electrical Engineering.

I still took a couple of basic Computer Science classes but I was nowhere close to where I need to be to get a coding interview in a big software company.

During my Ph.D. (which was in CS), I really wanted to get a software engineering internship because I knew this was crucial to get a full-time software engineering job after graduation.

I thought it was going to be easy but I was damn wrong.

The majority of the companies didn’t even get back to me.

The sound of silence was painful.

But why was I not given a chance?

My resume simply gave the wrong impression.

My resume was full of undergrad hardware projects.

Even though I mentioned all the CS classes I took and all the ones I taught, that was not convincing enough.

So I set out to reverse engineer this whole process.

I started to take more project-oriented CS classes and modified my resume to highlight these software projects.

I completely removed all the hardware projects from my resume.

This simple trick did it for me as I was able to get my first internship.

After the first internship, the process becomes exponentially easier.

This first internship opened the doors for an internship at a much bigger company the following year which in turn led to a very good position after graduation.

During these tough times, I learned a lot of lessons regarding the most efficient ways to get an interview.

I want to share with you my findings because I don’t want you to waste your time focusing on the wrong things.

It turns out your resume isn’t even the most efficient way to get an interview!

Here are the four most important things that will increase your chances of getting an interview (ordered by priority):

1- Referrals

This is by far the most efficient way to get an interview.

The most guaranteed way to get an interview at some company is to know someone who is already working there.

That said, I have got bad news and good news for you.

The good news: it doesn’t require a lot of work on your part.

All you have to do is write a nice email to your friend and ask for a referral.

The bad news: you just might not know anyone who works at the company.

Don’t worry.

Even though referrals are the most guaranteed way, they are not the only way.

There is one more thing that I consider very important.

That is your linkedin profile.

2- Professional Networking

Professional networking (both online and offline) is critical.

Not only will your professional network help with getting you an interview but also it plays a very big role in the progress of your career.

But what is professional networking?

It’s all about connecting with people who work in the same profession or industry and building a relationship with them.

Fortunately, Linkedin made this process much easier.

With a good professional network on Linkedin, instead of you reaching out to your friends for referrals, recruiters will be the ones reaching out to you.

With that said, it is extremely important to ensure your Linkedin profile is up to date.

Ever since I got my first job, I had numerous recruiters from various companies reaching out to me all thanks to my Linkedin profile.

Here is one from Facebook.

Here is another from Linkedin.

Still not convinced about the importance of your Linkedin profile?

Check how many people think that linkedin helped them get hired.

Here are some of the replies to a Quora question.

You can read their full answers on Quora.

Treat your Linkedin profile with the respect it deserves.

Always remember that there exists a recruiter somewhere whose main job is to find the best candidate.

Make it easy for him to find you!

3- Professional Experience

If you have been working for a decent software company for a couple of years, getting an interview at another company isn’t going to be tough.

But what if you are still a student?

Then try to get an internship asap!

Recruiters tremendously value past internships.

If it is tough to get an internship at a big tech company, aim at smaller companies or local startups.

Your first internship will open the doors for better future opportunities so try to get your first internship as soon as you can.

I know this because this is exactly what happened to me.

4- School Projects and Open Source Contribution

Another thing that will make your resume stand out is to showcase the software projects that you worked on.

This means that if you are in college, try to take as many project-oriented classes as possible.

Not only will this give you hands-on experience, but it will also help your resume stand out.

Also if you contribute to any open source project, make sure you write that down in your resume as well.

Of course, the impact of school projects and open source contributions is not as strong as referrals and professional experience.

But assuming everything else being equal, these projects will definitely help you stand out among other candidates with fewer projects to show on their resumes.

If you work on all the four aspects I discussed above, I assure you that will be invited to your first coding interview.

When this happens, big congratulations. All your hard work is paying off.

But now is the time to put this behind your back and focus on what’s next: your coding interviews.

It’s time to get yourself prepared.

One of my favorite quotes is “if you fail to prepare, you are preparing to fail”.

In the next section, I will teach you how to prepare for your imminent coding interviews.

Second: How to Prepare for the Coding Interview?

Now let’s cut to the chase.

How do you prepare for your coding interview?

First, let me put you in the right mindset.

If you try to google for generic job interview preparation questions, you will get the most useless answers.

I did that for you and here is the first result at Google.

Rest assured your interviewer will never ask you these questions.

Even if your interviewer asks you one of these lame questions, it’s probably because he/she ran out of intelligent questions to ask.

I can also assure you that your answers to these types of questions will have zero impact on the hiring decision.

So don’t waste your time trying to prepare for an intelligent answer to “what your weaknesses are” especially if you don’t have any 😉

Here is the thing.

Your coding interview is a technical interview.

Your interviewers care mostly about how technically sound you are.

They care about how competent and fast you are at solving problems.

So my advice to you is to spend your valuable preparation time focussing mainly and mostly on the technical aspects of the interview because this is what really matters.

With that said, here are the technical questions that you can expect in your coding interviews.

Questions to expect

1. Data Structures and Algorithms

Impact: very high
Frequency: very high

Most of the technical questions you will face in your coding interviews are related to data structures and algorithms.

If you don’t know what data structures are, then you need to build a strong foundation in computer science first before you are ready for the next steps.

In other words, if you are not familiar with terms like linked lists, trees, graphs, binary search, and dynamic programming (to name a few), then you have some work to do!

A solid understanding of data structures and algorithms help you write efficient programs that can run faster and utilize resources more efficiently.

It is one thing to write code that is functionally correct, it is a completely different thing to write efficient code that is functionally correct.

Interviewers value candidates who can analyze code, spot performance bottlenecks, and possibly come up with better solutions.

2. CS Fundamentals

Impact: high
Frequency: moderate

Data structures and algorithms are not the only technical questions you might face in an interview.

In fact, they are not my favorite questions to ask when I am interviewing a candidate.

Let’s face it, these questions have become so common that even sub-par candidates expect them and do very well in them.

A less frequent type of question that I personally like is about CS fundamentals.

Based on my experience, these are the questions that differentiate between an exceptional candidate and another who just memorized the solutions to common interview questions.

Questions in this category are very diverse.

They may include questions about networking, operating systems, distributed systems, and system design.

You will be surprised how many candidates I interviewed have very limited knowledge of what caching, virtual memory, or DNS is.

But once I ask them to write the code for a graph breadth-first search algorithm, they write the cleanest, most perfect error-free code. So don’t be that guy!

In all honesty, these questions are not asked as often as they should be and I really hope for that to change.

However, if they get asked and you showed a complete lack of knowledge, then it is definitely a red flag and might reduce your chances significantly.

Update:

I am happy to announce that this type of question is getting more popular these days by companies like Google, Uber, and Facebook.

They call it a “System Design interview” and this interview is meant to assess your ability to build and design large scale systems.Even though designing a large-scale system is a small subset of CS fundamentals, it is still a better way in my opinion to assess a candidate’s knowledge and understanding of the field of computer science.

With that said, I found the greatest resource online to prepare for system design interview questions.

It is very well written, in-depth, and open source so anyone can contribute.

3. Resume questions

Impact: moderate
Frequency: low

Unless you have years and years of experience, your resume doesn’t matter as much as your answers to the coding questions that you will be asked.

As soon as you start gaining more professional experience, the impact of your resume starts to gradually increase.

Make sure your resume is complete and honest.

Also, be prepared to answer any questions related to projects and prior work that you have participated in.

In general, the impact of resume questions is low especially if this is your first job.

Most of the time resume questions are just used to break the ice at the beginning of the interview.

4. Behavioral questions

Impact: low
Frequency: low

First, let me define what I mean by behavioral questions.

I am going to define behavioral questions as any non-technical questions.

Anything along the line of “Why do you want to work for our company?”, or “Are you a good team player?”

These questions often have no significant impact on the hiring decision.

However, I must say that your general behavior and the way you communicate matter a lot.

At the end of the day, we are human beings. Our psychology and human interactions affect our judgments and decisions.

Your Interviewers need to know that you are someone they can comfortably communicate and work with.

If your interviewer doesn’t like your behavior, it doesn’t matter how awesome you are at writing code.

You will probably get negative feedback.

Have I seen this happen before?

Absolutely!

I have seen super-stars get rejected because they wouldn’t give the interviewer a chance to talk to them.

I have also seen cases where candidates got rejected because they were extremely arrogant.

More surprisingly, I have seen cases where average candidates got hired because all interviewers enjoyed communicating with them.

Resources

Alright now let’s talk about resources.

What resources can help you prepare?

Most of the decent resources out there focus on the technical aspects of the interview.

They provide a large collection of coding interview questions and answers.

Here are my favorites.

1. Cracking the Coding Interview

“Cracking the Coding Interview” is a classic when it comes to technical interview preparation.

I can recommend this book because this is the book I used when I was preparing for my first coding interview.

I still remember those days as if they were yesterday.

It was an interview for a software internship position and I wanted to get the position so bad.

It took me over two weeks to go over most of the problems and the solutions but boy was it worth it.

I passed the interviews and I owe a lot of that to the time I dedicated to studying this book.

One thing to mention here, this book provides solutions in Java.

It is not hard though to translate the solutions to your language of choice even if you are not a Java expert.

2. LeetCode

Leetcode is an online resource that contains a ton of coding interview questions along with their solutions.

I recommend you go to their website and check out their problems section to have a general feel of how their problems look like.

As you can see, you can filter questions by topic or difficulty. Very neat feature!

Another cool thing about Leetcode is that you can submit your solutions in almost any popular programming language you want.

Leetcode will run your code against a suite of inputs and inform you if you pass all the test cases or not.

It will also notify you if your code is taking longer than expected to run (which indicates that your code could be optimized further).

Also, Leetcode has a forum where like-minded people discuss problems and solutions for every single problem on the site.

You can attempt a lot of questions on the site for free but their premium subscription is $35 per month.

Even though I haven’t personally used their premium service, I often use their free service to keep my coding skills sharp.

These are the resources I recommend.

Now I want to give you an idea of how the interview process looks like.

What are the steps that you will have to go through until you receive your offer letter?

Third: The Phone Interviews

This is the first round of interviews that you will have to go through.

The process

Your recruiter will contact you and schedule some time for a few back-to-back phone interviews.

The purpose of these interviews is to weed out bad candidates early on in the process.

That’s why they are sometimes called “Phone-screen” interviews.

Each phone interview usually lasts for 45 minutes to an hour.

What to expect in your phone interviews

Usually what happens is that your interviewer will call you on your phone and ask you a few programming questions.

You will be able to solve these questions in a shared document that both you and your interviewer can view and edit.

It is crucial to know in advance that you will be typing your code in a generic word editor, not an IDE.

No syntax highlighting, no auto-completion, no fancy features whatsoever so be prepared for that.

How to prepare for your phone interviews

These types of questions aren’t going to be different from what we have already discussed previously.

But because the purpose of these interviews is to weed out the sub-par candidates in a limited amount of time, expect your interviewer to jump straight into coding questions.

There is no time for lengthy resumes or behavioral questions.

Steve Yegge wrote an excellent article about what he expects from potential candidates during their phone interviews.

There are a few tips that will help you make the best out of this experience

  • Find a quiet place and get earphones. You need a quiet place to be able to give the interviewer and the questions your undivided attention. Trust me, even a tiny distraction can negatively impact your performance. You also need earphones because both your hands will be busy writing code. Don’t rely on your loudspeakers!
  • Practice writing code in regular text editors (not IDEs). You will be surprised how many programmers rely heavily on IDEs to write syntactically correct code
  • Think out loud. This is crucial! I understand that in real life you probably don’t talk out loud while you think, but for phone interviews, this is the only way your interviewer can assess your thinking process. Make sure you briefly discuss your potential solution with your interviewer before you start writing the code if possible.
  • Ask clarifying questions. Sometimes your interviewer will give you an incomplete problem to see if you will ask clarifying problems. Always ask questions if something is not clear or missing. If you are going to make any assumptions, discuss them with your interviewer first.

After your phone interviews, take a deep breath and relax!

It is a waiting game now.

Your recruiter will get back to you in a few days or weeks with general feedback on your performance and the decision they have come to.

If everything went well, then your recruiter will congratulate you and schedule some time for your next big milestone.

Your on-site interviews!

Fourth: The On-site Interviews

On-site interviews are fundamentally different from phone interviews.

I personally like on-site interviews more.

I mean I like to be interviewed face to face rather than be interviewed on the phone.

It is just easier to communicate with your interviewer face to face and it makes the whole process much simpler.

The process

The on-site interviews are usually 4~6 back-to-back interviews with different interviewers with various experience levels.

The whole process takes about 4~5 hours.

Your interviewer might ask you some resume questions, probably in an effort to break the ice and put you at ease.

Needless to say, you will also solve some programming problems on the whiteboard.

After the interview is finished, the next interviewer comes in and the whole process repeats.

How to prepare for your on-site interviews

Here are a few tips that worked for me.

Before your on-site interview, don’t try to practice new coding problems.

Because if you come across a new problem that you can’t solve, this will negatively impact your self-confidence.

And you ABSOLUTELY need your self-confidence.

At this stage, there are only two things you should focus on.

Sleep very well and arrive at your interview location early.

Having a good night’s sleep will help you maintain your sharpness and your focus.

I also like to arrive a little bit earlier just to familiarize myself with the location. It helps calm me down a little and put me at ease.

When your interview starts, again be prepared to talk out loud and discuss your solution and assumptions (if any) with your interviewer before you start coding away.

Even though it is generally easier to talk to a person face to face rather than on the phone, I have had experiences where the interviewers deliberately choose to show a poker face.

And it is not cool when your enthusiasm is faced with a poker face. It can be demoralizing.

If this happens to you, don’t panic and remember to maintain your focus and your confidence.

Fifth: After your Coding Interview

Relax.

There is nothing more you can do other than waiting for the final decision.

Your recruiter will contact you shortly after and inform you of their decision.

If the final decision is a hire, then big congratulations 🙂

Invite your friends and family over and have a big celebration.

Your recruiter will contact you again to discuss the details of your offer.

Very good times indeed!

If the final decision was no hire, it’s OK.

You will definitely be sad for some period of time.

But after your sadness is over, it’s time to analyze why you got a rejection.

Either one of two things could have happened:

1- You haven’t prepared well 

In this case, you know what to do.

Keep learning and improving yourself and then try again when you are ready.

2- It was outside of your control

Sometimes the rejection isn’t really under your control.

If you feel that you did well in your interviews and you still got a rejection,  just move on and try again later or try with a different company.

Good luck with your career!

With dedication and consistency, everything is possible 🙂

Featured Posts

Are you Beginning your Programming Career?

I provide my best content for beginners in the newsletter.

  • Python tips for beginners, intermediate, and advanced levels.
  • CS Career tips and advice.
  • Special discounts on my premium courses when they launch.

And so much more…

Subscribe now. It’s Free.

Subscribe
Notify of
7 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Ashwin
5 years ago

Very nice article. Thanks Karim for the insights. I will try to apply for an internship next year.

Nuhu Jerry
5 years ago

impressive and eye opener I really appreciate this!

Nagesh
4 years ago

Very well written with through knowledge. Great Job Karim

Caleb
3 years ago

Very well written and helpful, thanks!