Read this before you start solving problems on Leetcode (Prep Work)

Many people become discouraged because they believe they will be competing with young, recent graduates who have all the time in the world to review what they have just learned. That's amusing to me because many recent graduates are discouraged by the thought of competing against "professionals" with "real life experience" (whatever that means).

In reality, there isn't much competition. This isn't a zero-sum game. If you count the total number of software engineers in the job market (including new grads, professionals, self-taught devs, and Bootcamp grads) and compare it to the number of job openings, you will find that there are more software engineers than job openings.

They'll take you if you can just prove you're good enough. For talented engineers, there is almost no hiring limit, especially in larger tech firms. In many cases, if you perform well in the interview, they will be willing to create new roles for you. You'll be in good shape if you practise smartly and solve enough problems on Leetcode/CTCI. Don't be concerned about the competition.

Topics

This section is critical, so please pay close attention. Before you begin Leetcoding, you should review/study a list of important topics. You'll end up wasting your time if you don't. Remember the following two rules:

  1. Don’t spend too much time on the prep work.
  2. Don’t spend too little time on the prep work.

You will never be able to solve Leetcode/CTCI problems if you spend too much time studying. In contrast, if you spend too little time on preparation, you will be lost. To avoid wasting time, it is critical that you spend the appropriate amount of time on prep work.

Before you do anything, go over/learn the topics listed below. Anything else you learn could be a complete waste of your time. Some people study far more than they need to (for example, fancy graph algorithms, Spanning tree, A*, and so on) because they believe it will help them become better engineers. In my opinion, that is a complete waste of time. The majority of interviewers do not recall those topics. Once you've landed your dream job, you can learn them on your own. Don't squander your time. Just concentrate on learning the Data Structures and Algorithms listed below. There is nothing more or less.

Data Structures

  • Dynamic Array
  • Linked List
  • Stack & Queue
  • Hash Tables
  • Binary Search Tree
  • Binary Heaps & Priority Queue
  • Graphs
  • Trie

Algorithms

  • Bit Manipulation & Numbers — difference btw Unsigned vs signed numbers
  • Stability in Sorting
  • Mergesort
  • Quicksort
  • Heapsort — Sort it in-place to get O(1) space
  • Binary Search
  • Selections — Kth Smallest Elements (Sort, QuickSelect, Mediums of Mediums) — Implement all three ways
  • Permutations
  • Subsets
  • BFS Graph
  • DFS Graph
  • Dijkstra’s Algorithm (just learn the idea — no need to implement)
  • Tree Traversals — BFS, DFS (in-order, pre-order, post-order): Implement Recursive and Iterative
  • External Sort — No implementation; Just know the concept.
  • NP-Complete (Video) — Just know the concept
  • Topological Sort
  • Detect cycle in an undirected graph
  • Detect a cycle in a directed graph
  • Count connected components in a graph
  • Find strongly connected components in a graph

Prep work

Once you are comfortable with the data structures & algorithms above, do the following exercise multiple times (at least 2–3 times) until you can do them with your eyes closed.

  • Implement an ArrayList from scratch
  • Reverse a linked list
  • Implement a Stack & a Queue using Array
  • Implement a HashTable with simple Hashing functions
  • Implement a Graph using Adjacency List, and then write functions for BFS & DFS.
  • Write the binary search algorithm both recursively and iteratively
  • Write the merge sort algorithm
  • Write the quicksort algorithm
  • Print binary tree using DFS (in-order, preorder and post order — all three of them) and BFS.
  • Memorize time & space complexities for common algorithms. Here’s an interesting website.
  • Implement a trie.
  • Learn these important bit manipulation tricks.

Next Step

When you're finished with that, you can proceed to the next step. It could take anywhere from 2 weeks to 3 months to review Data Structures and Algorithms, depending on your level of comfort with them. It could take up to 6 months if you're a complete beginner (self-taught developer?).

Motivation

I commend you for taking the time to read the entire post. By doing so, you're already ahead of the game. I sincerely wish you the best of luck on your journey. These are the most challenging times in your engineering career. On the one hand, I want you to take everything seriously. On the other hand, I want you to understand that you will remember and treasure these moments. After you get your dream job, you will actually miss these precious moments of grinding and struggling to solve algorithmic challenges.

It took me a long time to get to where I am now. For a long time, I thought I was too stupid and dumb. When I was in college, I was comparing myself to smarter students and never imagined that I would be able to land lucrative offers from major tech companies.

I understand how difficult it is to complete all of these challenges. Leetcode is being talked about as if it were a piece of cake. It really isn't. Please don't lose heart.