DSA tutorials
277 articles · page 5 of 14Hand-written tutorials, ordered as a recommended learning path.
- 81 Queue via Two Stacks Implement a queue using two stacks with amortized O(1) operations. Covers costly enqueue vs costly dequeue approaches with Python code.
- 82 Two Pointer Advanced Master opposite-direction, same-direction, and fast-slow two pointer patterns. Includes templates, container with most water, cycle detection, and sort colors.
- 83 Stack via Two Queues Implement a stack using two queues with costly push and costly pop approaches. Complete Python solutions with complexity analysis.
- 84 Min Remove Parentheses Solve LeetCode 1249 Minimum Remove to Make Valid Parentheses using a stack. Two-pass and one-pass approaches with Python code and traces.
- 85 Basic Calculator I/II/III Solve Basic Calculator problems LeetCode 224, 227, and 772. Master stack-based expression evaluation with +, -, *, /, and parentheses in Python.
- 86 Reverse Polish Notation Solve LeetCode 150 Evaluate Reverse Polish Notation using a stack. Python implementation with division gotcha, traces, and complexity analysis.
- 87 Deque Design Patterns Master deque design patterns including sliding window maximum, palindrome checking, work stealing, and BFS/DFS hybrid. Python implementations.
- 88 Sliding Window Advanced Master fixed-size and variable-size sliding window techniques. Covers minimum window substring, longest substring with K distinct chars, and string permutation problems.
- 89 Simplify Unix Path Solve Simplify Path LeetCode 71 with a stack. Handle ., .., multiple slashes, and edge cases. Python solution with step-by-step trace.
- 90 Remove Duplicate Letters Solve LeetCode 316 Remove Duplicate Letters using monotonic stack with frequency and visited tracking. Smallest lexicographic subsequence in Python.
- 91 Car Fleet Solve LeetCode 853 Car Fleet using a stack. Sort by position, compare arrival times, and count fleets. Python solution with visual trace.
- 92 Priority Queue Patterns Master priority queue patterns for coding interviews. Top-K elements, merge K sorted lists, running median, and Dijkstra's algorithm in Python.
- 93 Next Smaller Element Solve the Next Smaller Element problem with a monotonic increasing stack in O(n). Python code, step-by-step trace, and reusable pattern for interviews.
- 94 Heap Advanced Patterns Master advanced heap patterns -- merge K sorted lists, find median from data stream with two heaps, top K elements, task scheduler, and more with Python heapq implementations.
- 95 Trap Rain Water (Stack) Solve Trapping Rain Water (LeetCode 42) using a stack-based approach. Python code with detailed trace, comparison with two-pointer, and complexity analysis.
- 96 Score of Parentheses Solve Score of Parentheses using a stack to track nested scores. Python solution with trace, O(n) time, plus the bit-shift trick for O(1) space.
- 97 Exclusive Time Functions Solve Exclusive Time of Functions with a stack simulating a call stack. Python solution with timestamps, detailed trace, and edge case handling.
- 98 Flatten Nested List Design a Flatten Nested List Iterator using a stack for lazy flattening. Python solution with iterator protocol, step-by-step trace, and design analysis.
- 99 Circular Deque Design a Circular Deque with front/rear pointers on a fixed-size array. Python solution with all O(1) operations, visual trace, and edge case handling.
- 100 Heap Sort Understand heap sort, why build-heap is O(n) not O(n log n), sift-down vs sift-up, in-place sorting, partial sort for top K, and comparisons with other sorts.