CONTENTS
Arrays
● Second Largest Element
● Move all Zeros to End
● Reverse an Array
● Rotate an Array
● Next Permutation
● Majority Element II
● Stock Buy and Sell (With No Limit)
● Stock Buy and Sell (With One Limit)
● Minimize the Heights
● Maximum Sum Subarray
● Maximum Product Subarray
● Maximum Sum Subarray in Circular
● First Missing Positive
String
● String to Integer - Your Own atoi()
● Add Two Binary Strings
● Anagram Check
● First Non-Repeating Character
● KMP Algorithm for Pattern Searching
● Min Chars to Add for Palindrome
● String Rotations of each other
Sorting
● Sort an array of 0s, 1s and 2s
● Count Inversions
● Merge Overlapping Intervals
● Insert and Merge Interval
CONTENTS
● Find Non-Overlapping Intervals
● Merge Two Sorted Arrays With Constant Extra Space
● Top K Frequent Elements
Searching
● Count Occurrences in a Sorted Array
● Minimum in a Sorted and Rotated Array
● Search in a Sorted and Rotated Array
● Peak Element
● K-th Element of Merged Two Sorted Arrays
● Aggressive Cows
● Allocate Minimum Pages
● Kth Missing Positive Number
Matrix
● Spiral Traversal
● Rotate Matrix
● Search in a sorted matrix
● Search in a row-wise sorted
● Search in a row-wise and column-wise sorted
● Set Matrix Zeroes
Hashing
● Pair with given sum - 2Sum
● Count Pairs with given sum
● Intersection of Two Sets
● Union of Two Sets
CONTENTS
● Longest Consecutive Subsequence
● Group Anagrams
● Count Subarrays with given sum
● Count Subarrays with given XOR
Two Pointer Technique
● Check for Pair Sum in Sorted
● Triplets in Sorted
● Triplets in Unsorted
● Print All Pairs with given sum
● Closest Pair
● Count Pairs in Sorted
● Subarray with given sum
● Count distinct elements in every window of size k
● Longest Substring With Distinct Characters
● Trapping Rain Water
● Container with most water
Prefix Sum
● Equilibrium Point
● Longest Subarray with Given Sum
● Longest Subarray with Equal No of 0s and 1s
● Product of Array except Self
● Find Starting Petrol Pump for Circular Tour
Linked List
CONTENTS
● Reverse a Linked List
● Rotate a Linked List
● Merge Two Sorted Lists
● Reverse a linked list in groups
● Sum two Linked Lists
● Clone a Linked List
● Detect Cycle
● First Node of the Cycle
● Remove Cycle
● LRU Cache
Backtracking
● Permutations of a String
● N Queens
● Solve the Sudoku
Tree
● Level Order Traversal
● Height of a Binary Tree
● Diameter of a Tree
● Invert Binary Tree
● Construct Tree from Inorder and Preorder
● Morris Traversal
● Boundary Traversal
● Maximum Path Sum
● Count all K Sum Paths in Binary Tree
● Is Valid BST
● K-th Smallest in BST
● Pair with given Sum in BST
CONTENTS
● Correct a BST with two nodes got swapped
● LCA in BST
● Serialize and Deserialize a Binary Tree
Heap
● K Largest Elements
● K closest point to origin
● Merge K Sorted Lists
● Median of a Stream
Stack
● Valid Parentheses
● Longest Valid Parentheses
● Next Greater Element
● Stock Span
● Largest Area in a Histogram
● Maximum and Minimum of every window size
● Min Stack
● Evaluate Reverse Polish Notation
● Decode the String
Queue and Deque
● Sliding Window Maximum
● Maximum score with jumps of at most length K
Dynamic Programming
CONTENTS
● Longest Increasing Subsequence
● Longest String Chain – Chain of words in an Array
● Longest Common Subsequence
● Longest Palindromic Subsequence
● Longest Palindromic Substring
● Count Palindromic Substring
● Edit Distance
● Stair Climbing
● Weighted Stair Climbing
● 0-1 knapsack
● Coin Change - Count Ways
● Count Change - Minimum Coins
● Minimum Jumps to Reach End
● Subset Sum Problem
● Partition Equal Subset Sum
● Stock Buy and Sell (Limit of K)
● Stock Buy and Sell (Limit of 2)
● House Robbing
● House Robbing (Circular)
● Count Possible Decodings of a Digit Sequence
● Matrix Chain Multiplication
● Boolean Parenthesization
● Word Break
Greedy
● Minimum Platforms
● Weighted Job Scheduling
● Job Sequencing
● Maximize Partitions with Unique Characters
CONTENTS
Graph
● DFS
● BFS
● Minimum time to Rot Oranges
● Cycle in an Undirected Graph
● Islands in a Graph
● Topological Sorting
● Cycle in a Directed Graph
● Redundant Connections - Bridges in a Graph
● Articulation Points
● Minimum Cost to connect all points
● Dijkstra's Algorithm
● Flood Fill
● Clone a Graph
● Alien Dictionary
● Distance from Source - Negative Weight Cycle
● Find the City With the Smallest Number of Neighbors at a
Threshold Distance
● Email Account Merging
Tries
● Implement Trie
● Word Search
● Maximum XOR of Two Numbers in an Array
Bit Manipulation
CONTENTS
● Find the only repetitive element between 1 to N-1
● Find the Missing Number
● Unique Number 1
● Unique Number 2
● Unique Number 3