Skip to main content
bynoor.io
Reference Guide

Technical Interview Preparation Kit

Data structures, algorithms, and system design. All in one place.

Introduction

I used to have some cheat sheets around to prepare myself for any incoming technical interviews, so I thought it would be a better idea to gather them here for quicker access. It could help someone else to prepare quickly as well :)

The order might not be so relevant. Pick and choose what you need to review.


Long-Term Preparation Kit

If I can afford only one book to prepare for my technical interviews, I will definitely buy the Cracking the Coding Interview book by Gayle McDowell, 6th edition. That's it, good luck!

Before You Continue

Check my new presentation on Cracking the Tech Job Interview to get a better understanding of the technical interview process, and what you can do to prepare for it - on the technical and non-technical sides.


Learn by Practice

If you prefer to learn by practising, I would advise you to start with Hackerank Preparation Kits.

Practice per Topic

The HackerRank Interview Preparation Kit

Recommended if you are a beginner or you need a refresher on a certain topic.

Practice on a Schedule

Interview Preparation Kits

Recommended if you have a scheduled interview, and you need to refresh your skills in different topics.


Short-Term Preparation Kit

If I don't have a long time to prepare, or if I already went through the long-term preparation kit before, and I want a quick refresh, I would follow this kit. Multiple resources and steps already summarize some topics from the Cracking the Coding Interview book I referred to above, with few modifications.

Video Kit: If I have a little more time, I would go through this playlist first, at least once.


Keep in Mind

Keep these data structures, algorithms, and concepts in mind:

Data Structures
  1. Linked Lists
  2. Trees, Tries, and Graphs
  3. Stacks and Queues
  4. Heaps
  5. Vectors and Array Lists
  6. >> Hash Tables << (Dictionaries, Maps, ...)
Algorithms
  1. Breadth-First Search
  2. Depth-First Search
  3. Binary Search
  4. Merge Sort
  5. Quick Sort
Concepts
  1. Memory (Stacks VS Heaps)
  2. Recursion
  3. Dynamic Programming
  4. Big O Time & Space
  5. Bit Manipulation

7 Steps to Solve Algorithm Problems

  1. Listen (& ask!).
  2. Pick an example which is:
    1. Big (enough)
    2. Is not a special case
  3. Use a brute-force approach (at least to think of the problem).
  4. Optimize your solution.
  5. Walk through your algorithm and know exactly what you are going to do before starting to code, think of needed variables and data structures for instance.
  6. Code! Make sure to have a:
    1. (Consistent) code style: Use descriptive variable names, and you may refer to them with abbreviations later.
    2. Modular code: before coding, not after.
  7. TEST!
    1. Don't use your original example.
    2. Analyze (line by line).
    3. Test with a:
      1. Small test case.
      2. Edge test case.
      3. Big test case.
    4. Test your code, not your algorithm!
    5. Think before fixing bugs (so that you won't introduce new bugs, or make the code missy or hard).
    6. Don't panic, you might not solve it from the first round.

3 Algorithm Strategies

  1. B.U.D.
    • Go through your brute-force or best solution right now and look for:
      1. Bottlenecks
      2. Unnecessary Work
      3. Duplicated Work
  2. Space & Time Tradeoffs
    • Always have hash tables at the top of your mind
  3. D.I.Y. (Do it Yourself)
    • Try to solve it in your mind, and write a code that behaves the same.
    • Use a large and generic example.
    • Reverse engineering your thoughts!

Bit Manipulation in a Nutshell


Linked Lists VS Arrays

Case # Operation / Data Structure Arrays Linked Lists
1 get (retrieve) Constant Linear
2 insert and delete (@ start) Linear Constant
3 insert and delete (@ end) Constant Linear

Clarifications:


Sort Algorithms

A great website to visualize and understand the different sorting algorithms is visualgo.net.

Algorithm Average Time Complexity Worst Time Complexity Worst Space Complexity Keys / Notes Stability
Best Time:
Quick Sort O(n lg n) O(n^2) O(lg n) Pivot could make things missy Not stable
Merge Sort O(n lg n) O(n lg n) O(n) Divide and conquer Stable
Heap Sort O(n lg n) O(n lg n) O(1) in-place Heapsort is significantly slower than Quicksort and Merge Sort, so Heapsort is less commonly encountered in practice. Not stable
Best Space:
Bubble Sort O(n^2) O(n^2) O(1) in-place Compare every pair and swap if they are not in order Stable
Insertion Sort O(n^2) O(n^2) O(1) in-place Compare every item with all previous items, if a smaller (a larger) item is found, move all items in between to right and insert that item in the correct place. Stable
Selection Sort O(n^2) O(n^2) O(1) in-place Find the smallest (largest) item and add it to the end of the sorted part. Usually worse than insertion sort. The first part is always sorted. Not stable

Search Algorithms

Algorithm Average / Worst Time Complexity Average / Worst Space Complexity Why to use? Notes
Binary Search O(lg n) O(lg n) Best time Works with sorted data only. Extra space is needed for the call stack in the recursive solution.
Linear Search O(n) O(1) in-place Best space Works with any (sorted or unsorted) data.

Trees

Tree Traversals


Binary Trees

Types

Useful Computations

In any perfect binary tree:


Graphs

A graph organizes items in an interconnected network. A graph consists of multiple nodes and edges between them.

Classifications

A graph could be:

Representations

A graph could be represented with:


SOLID Design Principles

Dependency Inversion

Interface Segregation

Liskov Substitution

Open-Closed

Separation of Concerns (Single Responsibility)


Sources and References

Last updated Sep 7, 2023