Grokking the Coding Interview

Become a Coding Interview Pro in 2024 with These 20 Must-Know Algorithmic Patterns!

Master coding interviews: How grokking coding interview patterns can help you prepare smartly.

Arslan Ahmad
Level Up Coding
Published in
6 min readJan 9, 2023

--

https://designgurus.org/course/grokking-the-coding-interview
Grokking the Coding Interview

Coding interviews can be a bit of a pain. Not only do they take a lot of time to prepare for, but during the actual interview, you have to present your solutions to someone who is evaluating you. It’s not something you usually have to deal with in your everyday life as a software engineer.

But even though coding interviews can be a bit of a hassle, I actually really enjoy working on algorithms and solving coding problems. It’s a fun exercise for me, and I love spending time on it. In this post, I want to share some of the techniques and lessons I’ve learned over time that make preparing for coding interviews an exciting and enjoyable experience.

A little about me

I’m the co-founder of Design Gurus and the author of Grokking series on coding and system design interviews. I have 20 years of experience in software engineering and have been through many interviews as both the interviewee and the interviewer. I have given around 30 interview loops, totaling over 120 interviews, and have personally sat through over 300 coding interviews and 200 system design interviews.

Problem Background

If you’re in the process of job hunting and preparing for coding interviews, chances are you’ve heard of LeetCode. It’s the go-to destination for coding interview questions and has a great community of engineers discussing algorithms. I personally love spending my free time on LeetCode, trying to solve new problems or learning from others’ solutions. It’s a great way to keep my skills sharp and stay up-to-date in the field.

Problems with LeetCode

One of the frustrating things about LeetCode is that it can be overwhelming — there are so many questions, and it’s hard to know where to start or what to focus on. I’m not sure if there’s a magic number of questions I should work through to feel prepared for a coding interview, but I do wish there was a more streamlined process that could guide me and teach me the necessary algorithmic techniques. As someone who is naturally a bit lazy, I don’t really feel like going through 500+ questions just for the sake of it. It would be great to have a more efficient way to learn and practice.

The Solution

A lot of people try to solve questions related to the same data structure, like working through all the array questions before moving on to linked lists, etc. While this does give some sense of organization, it’s not always coherent. For example, you might need to use a hash map for a bunch of different questions that require different algorithmic techniques. The best thing I’ve found is to focus on coding problem patterns like sliding window, fast and slow pointers, or topological sort. Once you’re familiar with a pattern, you can solve a bunch of different problems with it. It makes the whole process of preparing for coding interviews a lot more enjoyable and organized.

I’ve compiled a list of around 20 of these coding problem patterns that I think can really help people learn some powerful algorithmic techniques. It’s made a huge difference for me in interviews. If you want more details on these patterns and related problems with solutions, check out Grokking the Coding Interview.

So, without further delay, here is a list of all these patterns:

  1. Sliding Window
  2. Number of Island
  3. Two Pointers
  4. Fast & Slow Pointers
  5. Merge Intervals
  6. Cyclic Sort
  7. In-place Reversal of a LinkedList
  8. Tree Breadth-First Search
  9. Tree Depth First Search
  10. Two Heaps
  11. Subsets
  12. Modified Binary Search
  13. Bitwise XOR
  14. Top ‘K’ Elements
  15. K-way Merge
  16. 0/1 Knapsack
  17. Unbounded Knapsack
  18. Fibonacci Numbers
  19. Palindromic Subsequence
  20. Longest Common Substring
  21. Bonus: Topological Sort

Following is a small intro of each of these patterns with sample problems:

Thanks for reading

--

--

Founder www.designgurus.io | Formally a software engineer @ Facebook, Microsoft, Hulu, Formulatrix | Entrepreneur, Software Engineer, Writer.