Top Algorithms for Coding Interview
Comprehensive guide to essential algorithms and data structures
by Chinmay Murugkar
← Back to My Website
10
Categories
200+
Problems
100%
Coverage
String/Array/Matrix
Linked List
Tree, Heap & Trie
Graph
Sorting
Dynamic Programming
Bit Manipulation
Combinations & Permutations
Math
1. String/Array/Matrix
Rotate Array
Reverse Words in a String
Evaluate Reverse Polish Notation (Stack)
Isomorphic Strings
Word Ladder (BFS)
Word Ladder II (BFS)
Median of Two Sorted Arrays
Kth Largest Element in an Array
Wildcard Matching
Regular Expression Matching
Merge Intervals
Insert Interval
Two Sum
Two Sum II
Two Sum III
3Sum
4Sum
3Sum Closest
String to Integer
Merge Sorted Array
Valid Parentheses
Longest Valid Parentheses
Implement strStr()
Minimum Size Subarray Sum
Search Insert Position
Longest Consecutive Sequence
Valid Palindrome
ZigZag Conversion
Add Binary
Length of Last Word
Triangle
Contains Duplicate: I, II, III
Remove Duplicates from Sorted Array: I, II
Remove Element
Move Zeroes
Longest Substring Without Repeating Characters
Longest Substring that contains 2 unique characters [Google]
Substring with Concatenation of All Words
Minimum Window Substring
Find Minimum in Rotated Sorted Array: I, II
Search in Rotated Array: I, II
Min Stack
Majority Element: I, II
Bulls and Cows
Largest Rectangle in Histogram
Longest Common Prefix [Google]
Largest Number
Simplify Path
Compare Version Numbers
Gas Station
Pascal's Triangle: I, II
Container With Most Water
Candy [Google]
Trapping Rain Water
Count and Say
Search for a Range
Basic Calculator, Basic Calculator II
Group Anagrams
Shortest Palindrome
Rectangle Area
Summary Ranges
Increasing Triplet Subsequence
Get Target Using Number List And Arithmetic Operations
Reverse Vowels of a String
Flip Game, Flip Game II
Missing Number, Find the duplicate number, First Missing Positive
Valid Anagram, Group Shifted Strings
Top K Frequent Elements
Find Peak Element
Word Pattern, Word Pattern II
H-Index, H-Index II
Palindrome Pairs
One Edit Distance
Scramble String
First Bad Version
Integer to English Words
Text Justification
Remove Invalid Parentheses
Intersection of Two Arrays, Intersection of Two Arrays II
Sliding Window Maximum, Moving Average from Data Stream
Guess Number Higher or Lower
2. Matrix
Set Matrix Zeroes
Spiral Matrix
Spiral Matrix II
Search a 2D Matrix
Search a 2D Matrix II
Rotate Image [Palantir]
Valid Sudoku
Minimum Path Sum (DP) [Google]
Unique Paths (DP) [Google]
Unique Paths II (DP)
Number of Islands (DFS/BFS)
Number of Islands II (Disjoint Set)
Number of Connected Components in an Undirected Graph
Surrounded Regions (BFS)
Maximal Rectangle
Maximal Square
Word Search (DFS)
Word Search II
Range Sum Query 2D – Immutable
Longest Increasing Path in a Matrix (DFS)
Shortest Distance from All Buildings
Game of Life
Paint House, Paint House II
Sudoku Solver (DFS)
Walls and Gates (DFS/BFS)
Tic-Tac-Toe
Best Meeting Point
3. Linked List
Implement a Stack Using an Array
Add Two Numbers
Reorder List
Linked List Cycle
Copy List with Random Pointer
Merge Two Sorted Lists
Odd Even Linked List
Remove Duplicates from Sorted List
Remove Duplicates from Sorted List II
Partition List
LRU Cache
Intersection of Two Linked Lists
Remove Linked List Elements
Swap Nodes in Pairs
Reverse Linked List, Reverse Linked List II
Print Linked List in Reversed Order
Remove Nth Node From End of List (Fast-Slow Pointers)
Implement Stack using Queues
Implement Queue using Stacks
Palindrome Linked List
Implement a Queue using an Array
Delete Node in a Linked List
Reverse Nodes in k-Group
4. Tree, Heap and Trie
Binary Tree Traversal: Preorder, Inorder, Postorder, Level Order
Level Order II
Vertical Order
Invert Binary Tree
Kth Smallest Element in a BST
Binary Tree Longest Consecutive Sequence
Validate Binary Search Tree
Flatten Binary Tree to Linked List
Path Sum (DFS or BFS)
Path Sum II (DFS)
Construct Binary Tree from Inorder and Postorder Traversal
Construct Binary Tree from Preorder and Inorder Traversal
Convert Sorted Array to Binary Search Tree [Google]
Convert Sorted List to Binary Search Tree [Google]
Minimum Depth of Binary Tree
Binary Tree Maximum Path Sum
Balanced Binary Tree
Symmetric Tree
Binary Search Tree Iterator
Binary Tree Right Side View
Lowest Common Ancestor of a Binary Search Tree
Lowest Common Ancestor of a Binary Tree
Verify Preorder Serialization of a Binary Tree
Populating Next Right Pointers in Each Node
Populating Next Right Pointers in Each Node II
Unique Binary Search Trees (DP)
Unique Binary Search Trees II (DFS)
Sum Root to Leaf Numbers (DFS)
Count Complete Tree Nodes
Closest Binary Search Tree Value
Binary Tree Paths
Maximum Depth of Binary Tree
Recover Binary Search Tree
Same Tree
Serialize and Deserialize Binary Tree
Inorder Successor in BST
Find Leaves of Binary Tree
Largest BST Subtree
Heap
Merge k sorted arrays [Google]
Merge k Sorted Lists
Find Median from Data Stream
Meeting Rooms II, Meeting Rooms
Range Addition
Trie
Implement Trie (Prefix Tree)
Add and Search Word – Data structure design (DFS)
Segment Tree
Range Sum Query – Mutable
The Skyline Problem
5. Graph
Clone Graph
Course Schedule, Course Schedule II
Minimum Height Trees
Reconstruct Itinerary
Graph Valid Tree
6. Sorting
Bubble Sort
Selection Sort
Insertion Sort
Merge Sort
Quick Sort
Heap Sort
Counting Sort
Radix Sort
Bucket Sort
Merge Overlapping Intervals
Form the Largest Number
Sort array of 0s, 1s, and 2s
K'th Smallest/Largest
Minimum Platforms Required
Case-specific Sorting of Strings
Sort by Frequency
Minimum Operations for Distinct
7. Dynamic Programming
Edit Distance
Longest Common Subsequence
Knapsack Problem
Matrix Chain Multiplication
Coin Change
Maximum Subarray
Longest Increasing Subsequence
Word Break
House Robber
Jump Game
Best Time to Buy and Sell Stock
Decode Ways
Palindrome Partitioning
8. Bit Manipulation
Single Number
Reverse Bits
Number of 1 Bits
Maximum Binary Gap
Sum of Two Integers
Missing Number
Counting Bits
Bitwise AND of Numbers Range
Gray Code
Maximum Product of Word Lengths
9. Combinations and Permutations
Permutations
Permutations II
Permutation Sequence
Generate Parentheses
Combination Sum
Combinations
Letter Combinations of a Phone Number
Restore IP Addresses
Factor Combinations
10. Math
Reverse Integer
Palindrome Number
Pow(x, n), Power of Two, Power of Three, Power of Four
Subsets
Fraction to Recurring Decimal [Google]
Excel Sheet Column Number
Excel Sheet Column Title
Factorial Trailing Zeroes
Happy Number
Count Primes
Plus One
Divide Two Integers
Multiply Strings
Max Points on a Line
Product of Array Except Self
Integer Break
Add Digits
Ugly Number, Ugly Number II, Super Ugly Number
Find K Pairs with Smallest Sums