Algorithms & Data Structures
This project collects my understanding of common algorithms and data structures, along with related Java templates.
Algorithms
8 postsBinary Search
Search sorted spaces, control interval boundaries, and recognize common binary-search variants.
Sweep Line
Sort interval events, scan them in order, and turn overlap questions into state updates.
Backtracking and DFS
Explore search trees, manage path state, and distinguish reachability DFS from constraint-solving backtracking.
Breadth-First Search (BFS)
Traverse by layers, find shortest unweighted paths, and apply indegree-based topological sorting.
Sliding Window
Maintain a valid contiguous range and replace nested scans with a linear two-pointer pass.
Two Pointers
Coordinate two indices to exploit ordering, maintain ranges, and process linked structures in one pass.
Dynamic Programming
Define states and transitions for overlapping subproblems, from knapsacks to stock and subsequence families.
Greedy
Build a global solution from locally optimal choices when the problem's structure makes those choices safe.
Data Structures
3 postsTrees and BSTs
Represent binary trees, choose the right traversal, and exploit binary-search-tree ordering.
Monotonic Stack
Maintain ordered candidates to answer nearest-greater and nearest-smaller questions in linear time.
Stacks and Queues
Use LIFO, FIFO, deques, and priority queues to control processing order and preserve candidates.