For leetcode problems, the Python3 Solutions are published in jupyter notebook (still in progress). Check out more in Jupyter nbviewer.
Here, I summarized top common algorithms to deal with classic leetcode problems.
- Search for exact match
- Search for position to insert
- Sub-function (hard)
- Post-order Traversal Tree Problems
- 124. Binary Tree Maximum Path Sum
- 250. Count Univalue Subtrees
- 298. Binary Tree Longest Consecutive Sequence
- 508. Most Frequent Subtree Sum
- 543. Diameter of Binary Tree
- 549. Binary Tree Longest Consecutive Sequence II
- 687. Longest Univalue Path
- 1245. Tree Diameter
- Max Path Sum in a Grid
- Maximum number of unique prime factors
- Segment Tree / Binary Indexed Tree (Fenwick Tree)
- Morris Tree Traversal
- Disjoint Sets (Union Find)
- Shortest Paths Problems
- Dijkstra
- Floyd-Warshall
- Bellman-Ford
- SPFA
- BFS
- Bidirectional
- Multisource BFS
- Kahn's Algorithm - Topological sorting
- Cycle Detection Algorithms
- Tricolor DFS
- Floyd's Tortoise and Hare
- DFS
- Tarjan's algorithm
Strongly Connected Components (SCC) - Kruskal's Algorithm
- Maze router Problems
- Lee algorithm
- Euler Path (Hierholzer's algorithm)
- Permutations and Combinations
- Classic DP
- Knapsack problem
- Kadane's algorithm (DP approach to solve the largest contiguous elements in an array)
- Two-dimensional DP
- LIS series
- LCS series
- Palindromic Substring Other Solution: Middle-to-two-ends / Manacher
- Game Theory Other Solution: MinMax
- Interval Scheduling
Solution: Greedy / Boundary Counting- 56. Merge Intervals
- 252. Meeting Rooms
- 253. Meeting Rooms II
- 435. Non-overlapping Intervals
- 452. Minimum Number of Arrows to Burst Balloons
- 57. Insert Interval
- 352. Data Stream as Disjoint Intervals
- 436. Find Right Interval
- 616. Add Bold Tag in String
- 636. Exclusive Time of Functions
- 646. Maximum Length of Pair Chain
- 699. Falling Squares
- 715. Range Module
- 729. My Calendar I
- 731. My Calendar II
- 732. My Calendar III
- 759. Employee Free Time
- 986. Interval List Intersections
- 1109. Corporate Flight Bookings
- 1235. Maximum Profit in Job Scheduling
- 1288. Remove Covered Intervals - Boundary Counting doesn't work?
- Sliding window
- Easy
- Hard
- Substring search Template
- PreSum
- Stack
- Monotonic stack
- RPN (Reversed Polish Notation)
- Good stack problems
- 388. Longest Absolute File Path
- 496. Next Greater Element I
- 503. Next Greater Element II
- 636. Exclusive Time of Functions
- 856. Score of Parentheses
- 901. Online Stock Span
- 907. Sum of Subarray Minimums
- 1111. Maximum Nesting Depth of Two Valid Parentheses Strings
- 1130. Minimum Cost Tree From Leaf Values
- Bit Operation
- Sieve of Eratosthenes
- Integer Factorization
- Fourier Transform
- Modulo Arithmetic
- Link Analysis
- Reservoir Sampling
- Boyer-Moore Majority Vote algorithm
- Bézout's identity (GCD)
- Euclidean
- SLR(1)
- DFA - Deterministic Finite Automaton
- Round Robin
- 68. Text Justification Use case: Find the majority element in a list of values. Check this article.
- 169. Majority Element
- 229. Majority Element II
- 1150. Check If a Number Is Majority Element in a Sorted Array
- 1157. Online Majority Element In Subarray
* [65. Valid Number]() - DFA
* [136. Single Number]() - XOR
* [240. Search a 2D Matrix II]() - Start from Right-top Corner
- TBD