Image
Arslan Ahmad

Don’t Just LeetCode; Follow the Coding Patterns Instead

What if you don’t like to practice 100s of coding questions before the coding interview?
Image

Coding Interviews are getting harder to pass. To prepare for coding interviews, you will need weeks, if not months of preparation.

No one really likes spending that much time preparing for the coding interviews. So is there a smarter solution?

First, let’s look at the problem.

Anyone preparing for coding interviews definitely knows LeetCode. It is probably the biggest online repository for coding interview questions. Let’s take a look at what problems people face when using LeetCode.

Problems with LeetCode

There are more than 2k problems in LeetCode. The biggest challenge with LeetCode is its lack of organization; it has a huge set of coding problems, and one isn’t sure where to start or what to focus on.

One wonders, is there an adequate number of questions one should go through to consider themselves prepared for the coding interview?

I would love to see a streamlined process that guides me and teaches me enough algorithmic techniques to feel confident for the interview. As a lazy person myself, I wouldn’t like to go through 500+ questions.

The Solution

One technique that people often follow is to solve questions related to the same data structure; for example, focusing on questions related to Arrays, then LinkedList, HashMap, Heap, Tree, or Trie, etc. Although this does provide some organization, it still lacks coherence. For example, many questions can be solved using HashMaps but still require different algorithmic techniques.

I would love to see question sets that follow not only the same data structure but also similar algorithmic techniques.

The best thing I came across was the problem-solving patterns like Sliding Window, Fast and Slow Pointers, Topological Sort, etc. Following these patterns helped me nurture my ability to ‘map a new problem to an already known problem’. This not only made this whole coding-interview-preparation process fun but also a lot more organized.

Coding patterns enhance our “ability to map a new problem to an already known problem.” For a list of coding patterns, check Grokking the Coding Interview.

Coding Patterns

I have gathered around 20 of these coding problem patterns that I believe can help anyone learn these beautiful algorithmic techniques and make a real difference in the coding interviews.

The idea behind these patterns is that once you’re familiar with a pattern, you’ll be able to solve dozens of problems with it. For a detailed discussion of these patterns and related problems with solutions, take a look at Grokking the Coding Interview.

So, without further ado, let me list all these patterns:

  1. Sliding Window
  2. Islands (Matrix Traversal)
  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. Topological Sort
  17. 0/1 Knapsack
  18. Fibonacci Numbers
  19. Palindromic Subsequence
  20. Longest Common Substring

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

Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image

Conclusion

Like it or not, LeetCode-type questions are part of almost every programming interview, so every software developer should practice them before an interview. Their only option is to prepare smartly and learn problem-solving by focusing on the underlying problem patterns.

Learn more about these patterns and sample problems in Grokking the Coding Interview and Grokking Dynamic Programming for Coding Interviews.

Here are some interesting readings on Coding and System Design interviews:

Amazon
Apple
Coding Interview
Coding Interview Questions
Coding Patterns
Data Structures and Algorithms
Dynamic Programming Patterns
Facebook
FAANG
Google
Java
JavaScript
LeetCode
Python
Microsoft
More From Designgurus
Annual Subscription
$26
.25
/mo
billed yearly ($315)
Get instant access to all current and upcoming courses for one year.
Recommended Course
Image
Grokking Dynamic Programming Patterns for Coding Interviews
Join our Newsletter
Read More
Image
Arslan Ahmad
Mastering the Meta Technical Screen: A Comprehensive Guide for Senior Software Engineers
Image
Arslan Ahmad
The Roadmap To Clearing Technical Interview in 2024
Image
Arslan Ahmad
Amazon Top 18 Coding Interview Questions with Solutions
Image
Arslan Ahmad
Understanding the Top 10 Software Architecture Patterns: A Comprehensive Guide
Image
One-Stop Portal For Tech Interviews.
Copyright © 2024 Designgurus, Inc. All rights reserved.