DSA
Check if a root-to-leaf path sums to a target. Optimal — Time O(n), Space O(h).
4 approaches incl. Recursive, Memoized Version, Tabulation: Space Optimized, and more. Optimal — Time O(m*n), Space O(m*n).
Covers: Recursive, Memoized. Optimal — Time O(m*n), Space O(m*n).
Covers: Naive, Use Min Heap. Optimal — Time O(nlogk), Space O(1).
Covers: Brute Force - Set, Sliding Window + unordered M…, Other Optimization. Optimal — Time O(N), Space O(N).
Brute Force -> Sorting + Set approach. Optimal — Time O(nlogn), Space O(k).
4 approaches incl. Naive, Two Heaps, 1. How Do We Maintain the Me…, and more. Optimal — Time O(logn), Space O(n).
Covers: RECURSION, USING STACK, MORRIS MODIFIED.
Optimal approach.
Binary Trees. Time O(n), Space O(n).
Binary Trees problem — solution with code and analysis.
Covers: Recursive, Iterative. Optimal — Time O(n), Space O(n).
Covers: BFS (Level Order), DFS (Preorder, Right-First), DFS (Postorder, Left-First,…. Optimal — Space O(w).
Covers: O(1) Space — Level Pointer T…, BFS Level Order. Optimal — Time O(n), Space O(1).
Covers: DFS + Backtracking (Optimal), DFS with Running Sum (Accumu…, Iterative DFS with Explicit…. Optimal — Space O(n·h).
Binary Trees. Time O(n), Space O(h).
10 approaches incl. Recursive, Parent Pointers + Hash Set, Path Compression (Path to Ro…, and more. Optimal — Time O(n), Space O(h).
Covers: Recursion, Iterative. Optimal — Time O(n), Space O(n).
Covers: DFS with Height Tracking (Op…, Naive DFS (Two Separate Func…, DFS with Class-Level Variabl…. Optimal — Time O(n²), Space O(h).
Binary Trees. Time O(n × m), Space O(h).