Arrays:
Binary search,Sorting,sliding window,2 pointer, prefix sum, stacks,Greedy,DP
Questions:
704. Binary Search (E)
74. Search a 2D Matrix(M)
153. Finding Minimum in a sorted array(M)
33. search in a rotated array(M)
4. Median of two sorted arrays (H)
Decision Recursive Trees:
Trees,Tries,Graphs,Backtracking,Dyanmic programming,Binary tree,Combinatorics
Recursion:
uses Extra space
Questions: N Queens
Graphs:
Trees are special type of graph
Questions:
matrix graph – 200. Number of islands
adjacency list – 332. Reconstruct Itinerary
DFS:
Time: O(n)
if recursive, Hashset to detect cycle
or use stack
BFS:
Time: O(n)
Use Queue and Hashset to detect cycle
Union-Find:
Time: O(n logn)
Forest of trees
Questions:
323. Number of connected components in undirected graph
Topological Sort:
Time: O(n)
Hashset. Build on top of DFS. Directed acyclical graph – no cycle
269. Alien dictionary
Djikstra shortest path Algo:
weighted find shortest distance – E log V
Heap data structure Hashset
Minimum Spanning Tree (Prim’s or Kurshals algorithm):
Floyd Warshall’s Algorithms:
Hashmap:
Uses:
Count the occurrences of characters in string
Build an adjacency list for graph problems
Heaps:
Find max min element,Top K elements
Heapify – O(n), Insertion/Deletion – O(log n)
Questions:
K closest points to origin
Network Delay Time
Prim’s algo – Minimum cost to connect all points
Dynamic Programming:
Questions:
1143. Longest common Subsequence
322. Coin change