Cracking the Coding Interview [+10 Questions and Answers]

Cracking the Coding Interview [+10 Questions and Answers]

Written by WWC Team

Career Navigation

Sing your praises—

You made it to the coding interview! 

You nailed the HR interview, the cultural interview, and are one step closer to landing your dream job. You're ecstatic.

Then—reality hits you like a ton of bricks. You start to think if you’re ready for the biggest challenge to the tech hiring process.

You are confident in your coding skills, but there is still lingering doubt you’ll nail all the questions they ask. And when is the last time you wrote code from scratch? Are you sure you’re ready for such a task?

Stats don’t lie—people who are strong at coding still mess up the interview as much as 22 percent of the time

Don’t be part of this statistic.

In this post, you’ll learn how to crack the coding interview. You’ll learn what are the most common questions asked during the technical interview and the best answers. Plus, we’ve added some of the best resources to practice for the coding interview. 

To top it off, you’ll learn how to prepare for the dreaded behavioral questions as well. Let’s get you one step closer to landing this job.

The Basics of the Coding Interview

Programming is a hard skill.

It’s the reason why companies have such a rigorous coding interview. They quiz applicants to filter and rank them based on such skills. This differentiates tech applicants from others who apply to different positions because it is tied to your skill level.

Think of this as both a virtue and a vice. 

The good news—if you know how to program, you can demonstrate your chops without a degree or years of experience. You mastered a tractable list of problems so you can do a great deal.

The bad news—there is a massive gap between what you know and what your day-to-day tasks will be at your new position. There’s always a learning curve at a new job. But—technical interviews are often loaded with artificial questions. They don’t get to the crux of the issue—whether you will adapt and be good at your new position.

Worse, the questions are outdated. Imagine you walk into an interview and they ask you to write code entirely from scratch. When is the last time you did such a thing in your current position? You normally look up the part of the code you need from a plethora of libraries online. 

Don’t be surprised when you have these tasks during the interview. Before you start preparing for the technical questions, here are a few things to keep in mind.

  • Set proper expectations. You won’t always ace the technical interview. Don’t walk into the interview thinking you know it all. Most programmers fail the technical interview several times in their career, so it’s bound to happen to you. Don’t be discouraged if you fail the first time around but treat it like a learning exercise for the next one. 

  • Treat it like an exam. Imagine you have a scorecard. You need to show great results. If you want the highest grade, you better study and not slack off. Address those fuzzy areas you don’t know well and build on what you do know.

  • Know the basics of your language. The most common problems will come up in the technical interview. You need to have a basic understanding of what and how you can code in a chosen language.

  • Polish your field of expertise. If you’re a backend or frontend developer, you need to know terms like POST Request, GET request, the differences, and so on. More on this in the coming sections.

  • Know your tools. If you claim to know Memcache, you better know how it works and when to use it. A MySQL expert should know more than just syntax, but also best practices and how to design your database.

Now, let’s see what questions you have coming your way in the coding interview.

Prepare For These Coding Questions

What type of questions are typically asked in a coding interview?

Too many to mention. That’s why I compiled a list of questions asked by major software companies. You’re bound to encounter a variety of these questions, but remember, the onsite will be much more in-depth. The questions are ranked from easy (E) to medium (M) and hard (H).


  1. (E) What does ‘thread safety’ mean? It’s a concept in multithreading programming. The idea is to prevent race condition between the threads. Let’s say you write a line of code. You want it to function correctly during simultaneous execution by multiple threads. If it does function correctly, then it’s ‘thread-safe’.

  2. (M) What does ‘exception safety’ mean? It’s all about managing exceptions. There are three known ‘schools’ of thought on how to do it (look it up here). But it means programming in a way where no unexpected exception will be thrown.

  3. (H)What are some general tips to make sure memory doesn’t leak in C++ programs? The best idea is not to manage memory manually but to use smart pointers where applicable. But it’s important to remember that the easiest memory to manage is the memory you never allocated. Think of C# and Java. Everything is a reference. In C++ you should put objects on the stack whenever you can.

Data Structure

  1. (E) What is a priority queue? It’s an extension of a queue with three properties. First, every itme has a priority associated with it. Second, an element with a high priority is dequeued before an element with low priority. And last, if two elements have the same priority, they are served according to their order in the queue.

  2. (M) Check if the following given Binary Tree is Heap. Answer: no. How? Show all levels except last are full. Second, every node’s value should be greater than or equal to its child node (considering max-heap). Explain in detail.


Here are some other areas of data structures you’ll need to know and then be able to write your own code to showcase the concepts.

  • Array

  • Linked list

  • Hash table (collision mitigation mechanisms, understand what amortized constant-time means)

  • Trie

  • Linked hash map


  1. (M) What is a ‘critical section’? Let’s say you have to access a resource, some file, input or output port, or global data. A critical section is a group of instructions or a region of code needed to be executed atomically to access it.

Algorithms and Design Patterns

  1. (E) What’s so bad about ‘Singletons’? When used as a global instance, you hide the dependencies of your application in your code instead of exposing them through the interfaces. They also violate the single responsibility principle: by virtue of the fact that they control their own creation and lifecycle. And they inherently cause code to be tightly coupled, which makes faking them out under test difficult in many cases.

Make sure to code for these when practicing. Reading code someone else wrote will not cut it. It’s critical because you often have a gap in your knowledge and the only way to find this is by writing code. Review the following.

  • Sorting algorithms

  • All the prefix-tree searches

  • Traversals (Dijkstra’s, A*, BFS, DFS)


  1. (E) What does it mean to have a memory leak in Java? You have a memory leak when object references that are no longer needed and unnecessarily maintained. They are bad. They put unnecessary pressure on your machine as your programs consume more and more resources (point out with example).

  2. (M) Why does Java not support multiple inheritances? Java is a language that doesn’t support it, while something like C++ does. It doesn’t allow it because it tries to avoid the ambiguity caused by it. One example is the diamond problem that occurs in multiple inheritances.

Logic riddle

  1. The relationship between 2 animals is given: A is a child of B, C is a child of B, A is a child of D. An animal can be a child of 0-2 parents. Find out if two animals are related to each other.

Practice Applying the Knowledge

So—did you know the answers?

If yes, congratulate yourself. But it still doesn’t mean you’ll be able to answer them perfectly during your technical interview.

Let’s say you struggle practicing. Do some practice online—coders love GeeksforGeeks for example. Check out McDowell’s infamous book that gives you different questions and solutions.

Can you go at it alone? Fantastic. But here’s the proven process for preparation that works.

Start by coding answers to these questions. 

Force yourself to pretend you’re in an interview setting by solving them 10-15 minutes. Before you write a single line of code, organize your thoughts and figure out the solution. Then start coding.

Do the same in the interview. Make sure you validate with the interviewer your approach is a good one.

Keep on practicing. Rinse and repeat.

With this general knowledge, you’re one step closer to acing your coding interview!

About the Author

Roger is a Career Writer at Zety who focuses on the intersection between tech and the workplace. He tries to help people achieve the best possible career growth imaginable. In his spare time, he’s a taco connoisseur and loves old school Americana literature.