Coding Interview Patterns
Coding Interview Patterns
1. Pattern: Two Pointers
Introduction
Pair with Target Sum (easy) LeetCode
Squaring a Sorted Array (easy) LeetCode
Triplet Sum to Zero (medium) LeetCode
Triplet Sum Close to Target (medium) LeetCode
Triplets with Smaller Sum (medium) LintCode
Subarrays with Product Less than a Target (medium) LeetCode
Dutch National Flag Problem (medium) CoderByte
Problem Challenge 1: Quadruple Sum to Target (medium) Leetcode
Problem Challenge 2: Comparing Strings containing Backspaces (medium) Leetcode
2. Pattern: Fast & Slow pointers
Introduction emre.me
LinkedList Cycle (easy) Leetcode
Start of LinkedList Cycle (medium) Leetcode
Happy Number (medium) Leetcode
Middle of the LinkedList (easy) Leetcode
Problem Challenge 1: Palindrome LinkedList (medium) Leetcode
Problem Challenge 2: Rearrange a LinkedList (medium) Leetcode
Problem Challenge 3: Cycle in a Circular Array (hard) Leetcode
3. Pattern: Sliding Window
Introduction
Maximum Sum Subarray of Size K (easy)
Smallest Subarray with a given sum (easy) Educative.io
Longest Substring with K Distinct Characters (medium) Educative.io
Fruits into Baskets (medium) LeetCode
No-repeat Substring (hard) LeetCode
Longest Substring with Same Letters after Replacement (hard) LeetCode
Longest Subarray with Ones after Replacement (hard) LeetCode
Problem Challenge 1: Permutation in a String (hard) Leetcode
Problem Challenge 2: String Anagrams (hard) Leetcode
Problem Challenge 3: Smallest Window containing Substring (hard) Leetcode
Problem Challenge 4: Words Concatenation (hard) Leetcode
4. Pattern: Merge Intervals
Introduction Educative.io
Merge Intervals (medium) Educative.io
Insert Interval (medium) Educative.io
Intervals Intersection (medium) Educative.io
Conflicting Appointments (medium) Geeksforgeeks
Problem Challenge 1: Minimum Meeting Rooms (hard) Lintcode
Problem Challenge 2: Maximum CPU Load (hard) Geeksforgeeks
Problem Challenge 3: Employee Free Time (hard) CoderTrain
5. Pattern: Cyclic Sort
Introduction emre.me
Cyclic Sort (easy) Geeksforgeeks
Find the Missing Number (easy) Leetcode
Find all Missing Numbers (easy) Leetcode
Find the Duplicate Number (easy) Leetcode
Find all Duplicate Numbers (easy) Leetcode
Problem Challenge 1: Find the Corrupt Pair (easy) TheCodingSimplified
Problem Challenge 2: Find the Smallest Missing Positive Number (medium) Leetcode
Problem Challenge 3: Find the First K Missing Positive Numbers (hard) TheCodingSimplified
6. Pattern: In-place Reversal of a LinkedList
Introduction emre.me
Reverse a LinkedList (easy) Leetcode
Reverse a Sub-list (medium) Leetcode
Reverse every K-element Sub-list (medium) Leetcode
Problem Challenge 1: Reverse alternating K-element Sub-list (medium) Geeksforgeeks
Problem Challenge 2: Rotate a LinkedList (medium) Leetcode
7. Pattern: Stack
Introduction to Stack (Operations, Implementation, Applications)
Balanced Parentheses
Reverse a String
Decimal to Binary Conversion
Next Greater Element Leetcode - I Leetcode -II Leetcode - III (Hard)
Sorting a Stack
Simplify Path Leetcode
8. Pattern: Monotonic Stack
Introduction to Monotonic Stack
Next Greater Element (easy) Leetcode - I Leetcode -II Leetcode - III (Hard)
Daily Temperatures (easy) Leetcode
Remove Nodes From Linked List (easy) Leetcode
Remove All Adjacent Duplicates In String (easy) Leetcode
Remove All Adjacent Duplicates in String II (medium) Leetcode
Remove K Digits (hard) Leetcode
9. Pattern: Hash Maps
Introduction (Hashing, Hash Tables, Issues)
First Non-repeating Character (easy) Leetcode
Largest Unique Number (easy) Leetcode+
Maximum Number of Balloons (easy) Leetcode
Longest Palindrome(easy) Leetcode
Ransom Note (easy) Leetcode
10. Pattern: Tree Breadth First Search
Introduction
Binary Tree Level Order Traversal (easy) Leetcode
Reverse Level Order Traversal (easy) Leetcode
Zigzag Traversal (medium) Leetcode
Level Averages in a Binary Tree (easy) Leetcode
Minimum Depth of a Binary Tree (easy) Leetcode
Maximum Depth of a Binary Tree (easy) Leetcode
Level Order Successor (easy) Geeksforgeeks
Connect Level Order Siblings (medium) Leetcode
Problem Challenge 1: Connect All Level Order Siblings (medium) Educative
Problem Challenge 2: Right View of a Binary Tree (easy) Leetcode
11. Pattern: Tree Depth First Search
Introduction
Binary Tree Path Sum (easy) Leetcode
All Paths for a Sum (medium) Leetcode
Sum of Path Numbers (medium) Leetcode
Path With Given Sequence (medium) Geeksforgeeks
Count Paths for a Sum (medium) Leetcode
Problem Challenge 1: Tree Diameter (medium) Leetcode
Problem Challenge 2: Path with Maximum Sum (hard) Leetcode
12. Pattern: Graphs
Introduction to Graph (Representations, Abstract Data Type (ADT))
Graph Traversal: Depth First Search(DFS)
Graph Traversal: Breadth First Search (BFS)
Find if Path Exists in Graph(easy) Leetcode
Number of Provinces (medium) Leetcode
Minimum Number of Vertices to Reach All Nodes(medium) Leetcode
13. Pattern: Island (Matrix traversal)
Introduction to Island Pattern
Number of Islands (easy) Leetcode
Biggest Island (easy)
Flood Fill (easy) Leetcode
Number of Closed Islands (easy) Leetcode
Problem Challenge 1 (easy)
Problem Challenge 2 (medium)
Problem Challenge 3 (medium)
14. Pattern: Two Heaps
Introduction
Find the Median of a Number Stream (medium) Leetcode
Sliding Window Median (hard) Leetcode
Maximize Capital (hard) Leetcode
*Maximum Sum Combinations (medium) InterviewBit
15. Pattern: Subsets
Introduction Educative.io
Subsets (easy) Educative.io
Subsets With Duplicates (easy) Educative.io
Permutations (medium) Educative.io
String Permutations by changing case (medium)
Balanced Parentheses (hard)
Unique Generalized Abbreviations (hard) Leetcode
Introduction Complete Pattern Theory and Solutions
Order-agnostic Binary Search (easy) Geeksforgeeks
Ceiling of a Number (medium) Geeksforgeeks-Ceil Geeksforgeeks-Floor
Next Letter (medium) Leetcode
Number Range (medium) Leetcode
Search in a Sorted Infinite Array (medium) Leetcode
Minimum Difference Element (medium): Find the floor & ceil take the difference, minimum would be the ans
Bitonic Array Maximum (easy) Geeksforgeeks
Problem Challenge 1: Search Bitonic Array (medium) Leetcode
Problem Challenge 2: Search in Rotated Array (medium) Leetcode
Problem Challenge 3: Rotation Count (medium) Geeksforgeeks
*Search a 2D Matrix (medium) Leetcode
*Minimum Number of Days to Make m Bouquets (medium) Leetcode
*Koko Eating Bananas (medium) Leetcode
*Capacity To Ship Packages Within D Days (medium) Leetcode
*Median of Two Sorted Arrays (hard) Leetcode
17. Pattern: Bitwise XOR
Introduction
Single Number (easy)
Two Single Numbers (medium)
Complement of Base 10 Number (medium)
Problem Challenge 1: Flip and Invert an Image (hard)
18. Pattern: Top 'K' Elements
Top 'K' Numbers (easy) Solution
Kth Smallest Number (easy)
'K' Closest Points to the Origin (easy) Leetcode
Connect Ropes (easy)
Top 'K' Frequent Numbers (medium)
Frequency Sort (medium)
Kth Largest Number in a Stream (medium) Leetcode
'K' Closest Numbers (medium)
Maximum Distinct Elements (medium)
Sum of Elements (medium)
Rearrange String (hard)
Problem Challenge 1: Rearrange String K Distance Apart (hard)
Problem Challenge 2: Scheduling Tasks (hard)
Problem Challenge 3: Frequency Stack (hard)
19. Pattern: K-way merge
Introduction
Merge K Sorted Lists (medium) Leetcode
Kth Smallest Number in M Sorted Lists (Medium) Geeksforgeeks
Kth Smallest Number in a Sorted Matrix (Hard) Educative.io
Smallest Number Range (Hard) Leetcode
Problem Challenge 1: K Pairs with Largest Sums (hard)
20. Pattern: Greedy Algorithms
Introduction to Greedy Algorithm
Valid Palindrome II (easy) Leetcode
Maximum Length of Pair Chain (medium) Leetcode
Minimum Add to Make Parentheses Valid (medium) Leetcode
Remove Duplicate Letters (medium) Leetcode
Largest Palindromic Number (Medium) Leetcode
Removing Minimum and Maximum From Array (medium) Leetcode
21. Pattern : 0/1 Knapsack (Dynamic Programming)
Introduction
0/1 Knapsack (medium) Geeksforgeeks
Equal Subset Sum Partition (medium) Leetcode
Subset Sum (medium) Geeksforgeeks
Minimum Subset Sum Difference (hard) Geeksforgeeks
Problem Challenge 1: Count of Subset Sum (hard)
Problem Challenge 2: Target Sum (hard)
22. Pattern: Backtracking
Introduction to Backtracking Pattern
Combination Sum (medium) Leetcode - I Leetcode - II Leetcode - III Leetcode - IV
Word Search (medium) Leetcode - I Leetcode - II (Hard)
Sudoku Solver (hard) Leetcode
Factor Combinations (medium) Leetcode+
Split a String Into the Max Number of Unique Substrings (medium) Leetcode
23. Pattern: Trie
Introduction to Trie
Implement Trie (Prefix Tree) (medium) Leetcode
Index Pairs of a String (easy) Leetcode+
Design Add and Search Words Data Structure (medium) Leetcode
Extra Characters in a String (medium) Leetcode
Search Suggestions System (medium) Leetcode
24. Pattern: Topological Sort (Graph)
Introduction
Topological Sort (medium) Youtube
Tasks Scheduling (medium) Leetcode-Similar
Tasks Scheduling Order (medium) Leetcode-Similar
All Tasks Scheduling Orders (hard) Leetcode-Similar
Alien Dictionary (hard) Leetcode
Problem Challenge 1: Reconstructing a Sequence (hard) Leetcode
Problem Challenge 2: Minimum Height Trees (hard) Leetcode
25. Pattern: Union Find
Introduction to Union Find Pattern
Redundant Connection (medium) Leetcode - I Leetcode - II (Hard)
Number of Provinces (medium) Leetcode
Is Graph Bipartite? (medium) Leetcode
Path With Minimum Effort (medium) Leetcode
26. Ordered Set
Introduction to Ordered Set Pattern
Merge Similar Items (easy) Leetcode
132 Pattern (medium) Leetcode
My Calendar I (medium) Leetcode Leetcode - II Leetcode - III (Hard)
Longest Continuous Subarray (medium)
27. Pattern: Multi-thread
Introduction to Multi-threaded Pattern
Same Tree (medium)
Invert Binary Tree (medium)
Binary Search Tree Iterator (medium)
28. Miscellaneous
Kth Smallest Number (hard)
Revision
Test Your Knowledge
Note: Problems marked with
*
are added as per my recommendations.
Last updated