Skip to content

sanghyun-s/leetcode-study

Repository files navigation

📚 LeetCode Study Log — 2026

Goal: Build pattern recognition through systematic practice
Study Pace: 3-7 problems/day
Mentor Review: Weekly
Focus: Python3 + SQL


📊 Progress Dashboard

Day Date Easy Medium Hard Category Status
Day 1 05/15 7 4 0 Arrays, Hash Map, Sorting, Backtracking ✅ Complete
Day 2 (Makeup) 05/16 6 1 0 Sorting, Brute Force ✅ Complete
Day 3 05/15 2 2 0 DFS/Trees ✅ Complete
Day 4A 05/16 4 2 1 SQL/MySQL ✅ Complete
Day 4B 05/16 2 1 0 Matrix Traversal ✅ Complete
Day 5 05/18 3 3 0 Greedy Algorithm ✅ Complete
Day 6 05/19 2 1 0 Hash Map / Hash Set ✅ Complete
(Gap: final exams + app projects) 05/20–06/03 Returned 6/4 — honest log 📝 Noted
Day 8 06/04 18 2 0 Mixed (DP, Bit, Prefix Sum, Matrix, SQL, Simulation) ✅ Complete
Day 9 06/05 7 3 0 Strings + Tree DFS ✅ Complete

🔢 Total Solved

  • 🟢 Easy: 51
  • 🟡 Medium: 19
  • 🔴 Hard: 1
  • Total: 71

🔥 Current Stats

  • Study streak: Day 9 🔥 (consecutive comeback days after exam-week gap; 30 problems across Days 8-9)
  • Patterns learned: Arrays, Hash Map, Hash Set, Two Pointers, Binary Search, Backtracking, Sorting, DP/Fibonacci, DP/Bit, DFS Trees (5 sub-patterns), Window Functions, JOIN, GROUP BY+DISTINCT, CROSS JOIN, Anti-Join, String Manipulation (5 sub-patterns), Spiral Traversal, Greedy, Bit Manipulation, XOR+Popcount, Counting Sort, Matrix Diagonal, Prefix Sum, Enumeration, Subset Bitmask, Permutation Frequency Trick, In-Place Bit Packing, Simulation, Manhattan Distance, Tree DFS (4 flavors)
  • Languages: Python3, SQL/MySQL
  • Next up: Sliding Window & Stack — Medium-difficulty pattern drill

📋 PROBLEM LOG BY DAY


DAY 1 | May 15, 2026 | 11 Problems (7 Easy + 4 Medium)

Easy (7)

# Title Pattern Date Link
1 Two Sum Hash Map 2026-05-15 View
14 Longest Common Prefix String 2026-05-15 View
26 Remove Duplicates Two Pointers 2026-05-15 View
27 Remove Element Two Pointers 2026-05-15 View
35 Search Insert Position Binary Search 2026-05-15 View
66 Plus One Array/Math 2026-05-15 View
88 Merge Sorted Array Two Pointers 2026-05-15 View

Medium (4)

# Title Pattern Date Link
11 Container with Most Water Greedy/TP 2026-05-15 View
15 Three Sum Two Pointers 2026-05-15 View
39 Combination Sum Backtracking 2026-05-15 View
46 Permutations Backtracking 2026-05-15 View

DAY 2 | May 15-16, 2026 | 6 Problems (4 Easy + 2 Medium)

Easy (4)

# Title Pattern Date Link
905 Transform Array by Parity Sorting 2026-05-15 View
1679 Count Pairs Sum < Target Sorting 2026-05-15 View
2050 Count Numbers Unique Digits Brute Force 2026-05-15 View
2418 Sort the People Sorting/Hash Map 2026-05-15 View

Medium (2)

# Title Pattern Date Link
2541 Min Cost Split into Ones DP 2026-05-15 View
2545 Sort Students by Kth Score Sorting 2026-05-15 View

DAY 3 | May 15-16, 2026 | 4 Problems (2 Easy + 2 Medium)

Easy (2)

# Title Pattern Date Link
938 Range Sum of BST Trees/DFS 2026-05-15 View
1379 Find Corresponding Node in Clone Trees/DFS 2026-05-15 View

Medium (2)

# Title Pattern Date Link
1038 BST to Greater Sum Tree Trees/DFS 2026-05-15 View
2265 Count Nodes Equal to Average Trees/DFS 2026-05-15 View

DATABASE SESSION | May 16, 2026 | 7 Problems (4 Easy + 2 Medium + 1 Hard)

Easy (4) - SQL

# Title Pattern Date Link
1350 Students Invalid Departments JOIN/Anti-join 2026-05-16 View
1303 Find Team Size Window Functions 2026-05-16 View
1757 Recyclable and Low Fat WHERE/AND 2026-05-16 View
1571 Warehouse Manager JOIN/GROUP BY 2026-05-16 View

Medium (2) - SQL

# Title Pattern Date Link
3204 Bitwise User Permissions Bitwise/Aggregate 2026-05-16 View
2989 Class Performance Calculation 2026-05-16 View

Hard (1) - SQL

# Title Pattern Date Link
3368 First Letter Capitalization Recursive CTE 2026-05-16 View

MATRIX SESSION | May 16, 2026 | 3 Problems (2 Easy + 1 Medium)

Easy (2)

# Title Pattern Date Link
1672 Richest Customer Wealth Row Sum/Max 2026-05-16 View
2373 Largest Local Values Sliding Window 2026-05-16 View

Medium (1)

# Title Pattern Date Link
885 Spiral Matrix III Simulation/Spiral 2026-05-16 View

Day 5 | May 18, 2026 | 6 Greedy Problems (3 Easy + 3 Medium)

Easy (3)

# Title Pattern Date Link
1221 Split a String in Balanced Strings Balance Tracking 2026-05-18 View
2037 Seat Everyone Sort + Pair 2026-05-18 View
2160 Minimum Sum Four Digits Digit Placement 2026-05-18 View

Medium (3)

# Title Pattern Date Link
1689 Partitioning Deci-Binary Max Digit Insight 2026-05-18 View
1874 Minimize Product Sum Pair Opposites 2026-05-18 View
1282 Group People by Size Bucket + Split 2026-05-18 View

Day 6 | May 19, 2026 | 3 Problems (2 Easy + 1 Medium)

Easy (2)

# Title Pattern Date Link
1512 Number of Good Pairs Hash Map / Counting 2026-05-19 View
3668 Restore Finishing Order Hash Set / Filter 2026-05-19 View

Medium (1)

# Title Pattern Date Link
3760 Maximum Substrings With Distinct Start Hash Set / Distinct Count 2026-05-19 View

Day 8 | June 4, 2026 | 20 Problems (18 Easy + 2 Medium) — Resumed after exam-week gap

Catch-up session. Took a 2-week break for finals + capstone polish + LinkedIn launch. Resumed with a deliberate "variety + volume" run across multiple patterns to rebuild momentum. Hit 2x the original 10-problem goal across DP, Bit Manipulation, Prefix Sum, Matrix, Enumeration, Simulation, and SQL — and added 2 Mediums.

Easy — DP / Bit Manipulation (2)

# Title Pattern Date Link
70 Climbing Stairs DP / Fibonacci 2026-06-04 View
338 Counting Bits DP / Bit Manipulation 2026-06-04 View

Easy — Sorting / Greedy (3)

# Title Pattern Date Link
349 Intersection of Two Arrays Two Pointers / Hash Set 2026-06-04 View
561 Array Partition Greedy / Sorting 2026-06-04 View
1051 Height Checker Sorting / Counting Sort 2026-06-04 View

Easy — Enumeration (2)

# Title Pattern Date Link
1863 Sum of All Subset XOR Totals Bit Manipulation / Subset Enum 2026-06-04 View
2843 Count Symmetric Integers Enumeration / Digit Manipulation 2026-06-04 View

Easy — Matrix (1)

# Title Pattern Date Link
1572 Matrix Diagonal Sum Matrix / Diagonal Indexing 2026-06-04 View

Easy — Prefix Sum (2)

# Title Pattern Date Link
1480 Running Sum of 1d Array Prefix Sum 2026-06-04 View
2574 Left and Right Sum Differences Prefix Sum / Two Pass 2026-06-04 View

Easy — SQL (3)

# Title Pattern Date Link
1821 Find Customers With Positive Revenue This Year SQL / WHERE Filter 2026-06-04 View
2339 All the Matches of the League SQL / CROSS JOIN 2026-06-04 View
2356 Number of Unique Subjects Taught by Each Teacher SQL / GROUP BY + COUNT DISTINCT 2026-06-04 View

Easy — Bit Manipulation (3)

# Title Pattern Date Link
1684 Count the Number of Consistent Strings Bit Manipulation / Set Membership 2026-06-04 View
2220 Minimum Bit Flips to Convert Number Bit Manipulation / XOR + Popcount 2026-06-04 View
3173 Bitwise OR of Adjacent Elements Bit Manipulation / Array Traversal 2026-06-04 View

Easy — Simulation (2)

# Title Pattern Date Link
1920 Build Array from Permutation Simulation / In-Place Bit Packing 2026-06-04 View
2011 Final Value of Variable After Performing Operations Simulation / String Inspection 2026-06-04 View

Medium — SQL (1)

# Title Pattern Date Link
2084 Drop Type 1 Orders for Customers With Type 0 Orders SQL / Anti-Join + Window Function 2026-06-04 View

Medium — Hash / Bit Manipulation (1)

# Title Pattern Date Link
2657 Find the Prefix Common Array of Two Arrays Hash / Permutation Frequency Trick 2026-06-04 View

Day 9 | June 5, 2026 | 10 Problems (7 Easy + 3 Medium) — Strings + Tree DFS

Day 2 of comeback. Focused on two pattern families: strings (5 problems building from adjacent-pair aggregation to two-pass prefix sums) and tree DFS (5 problems covering all four DFS flavors: read, compare, aggregate, mutate, then composing them for the Medium). Hit the 10-problem mark with strong pattern recognition — the string problems built on yesterday's adjacent-pair templates, and the trees ended with a Medium that explicitly composes two earlier patterns.

Easy — String / Adjacent Pair (1)

# Title Pattern Date Link
3110 Score of a String String / Adjacent Pair Aggregation 2026-06-05 View

Easy — String / Filter (2)

# Title Pattern Date Link
1119 Remove Vowels from a String String / Filter / Set Membership 2026-06-05 View
2942 Find Words Containing Character String / Indexed Filter 2026-06-05 View

Easy — Tree DFS (4)

# Title Pattern Date Link
94 Binary Tree Inorder Traversal Tree / DFS / Iterative Stack 2026-06-05 View
100 Same Tree Tree / Parallel DFS 2026-06-05 View
104 Maximum Depth of Binary Tree Tree / DFS Aggregation 2026-06-05 View
226 Invert Binary Tree Tree / DFS Mutation 2026-06-05 View

Medium — String (2)

# Title Pattern Date Link
1769 Minimum Operations to Move All Balls to Each Box String / Two-Pass Prefix Sum 2026-06-05 View
3846 Total Distance to Type a String Using One Finger String / Hash Map / Manhattan 2026-06-05 View

Medium — Tree DFS (1)

# Title Pattern Date Link
1382 Balance a Binary Search Tree Tree / Inorder + Divide & Conquer Rebuild 2026-06-05 View

🧩 Pattern Summary

Pattern Easy Medium Hard Total
Hash Map 2 0 0 2
Hash Set 2 1 0 3
Hash / Permutation Trick 0 1 0 1
Two Pointers 4 1 0 5
Binary Search 1 0 0 1
Backtracking 0 2 0 2
Sorting 4 1 0 5
Sorting/Hash Map 1 0 0 1
Counting Sort 1 0 0 1
DP / Fibonacci 1 0 0 1
DP / Bit Manipulation 1 0 0 1
DP (other) 0 1 0 1
Bit Manipulation / Subset 1 0 0 1
Bit Manipulation / Set 1 0 0 1
Bit Manipulation / XOR 1 0 0 1
Bit Manipulation / Adjacent 1 0 0 1
Greedy / Sorting 1 0 0 1
Greedy/TP 0 1 0 1
Greedy/Balance 1 0 0 1
Greedy/Sort 1 0 0 1
Greedy/Digit 1 0 0 1
Greedy/Bucket 0 1 0 1
Greedy/Max Digit 0 1 0 1
Greedy/Pair 0 1 0 1
Enumeration / Digit 1 0 0 1
Prefix Sum 2 0 0 2
Prefix Sum / Two-Pass Sweep 0 1 0 1
Matrix / Diagonal 1 0 0 1
Simulation / Bit Packing 1 0 0 1
Simulation / String 1 0 0 1
String / Adjacent Pair 1 0 0 1
String / Filter 1 0 0 1
String / Indexed Filter 1 0 0 1
String / Hash Map / Manhattan 0 1 0 1
String (basic) 1 0 0 1
Array/Math 1 0 0 1
Brute Force 1 0 0 1
Trees/DFS (Day 3) 2 2 0 4
Tree DFS / Inorder 1 0 0 1
Tree DFS / Parallel 1 0 0 1
Tree DFS / Aggregation 1 0 0 1
Tree DFS / Mutation 1 0 0 1
Tree DFS / Inorder + Rebuild 0 1 0 1
SQL/Bitwise 0 1 0 1
SQL/JOIN 1 0 0 1
SQL/Window Fn 1 0 0 1
SQL/Calculation 0 1 0 1
SQL/Recursive CTE 0 0 1 1
SQL/WHERE Filter 1 0 0 1
SQL/CROSS JOIN 1 0 0 1
SQL/GROUP BY + DISTINCT 1 0 0 1
SQL/Anti-Join 0 1 0 1
Matrix/Row Sum 1 0 0 1
Matrix/Sliding Win 1 0 0 1
Matrix/Spiral 0 1 0 1
Total 51 19 1 71

📚 Key Learnings

Day 1-2: Arrays & Sorting

  • Hash map for O(n) lookups
  • Two-pointer technique for sorted arrays
  • Sorting with custom keys in Python
  • Greedy algorithms

Day 3: Trees & DFS

  • Post-order traversal for subtree aggregation
  • Tuple returns (sum, count) pattern
  • Parallel tree traversal
  • BST properties for optimization

Database: SQL Patterns

  • Aggregate functions (BIT_AND, BIT_OR, COUNT, MAX, MIN)
  • Anti-join pattern (LEFT JOIN + IS NULL)
  • Window functions (PARTITION BY)
  • Recursive CTE for iterative processing
  • String manipulation with REGEXP

Matrix: Traversal Patterns

  • Row sum and max finding
  • 2D sliding window (3×3)
  • Spiral traversal with direction vectors
  • Step size patterns (1,1,2,2,3,3...)
  • (Day 8) Diagonal indexing: (i, i) for primary, (i, n-1-i) for secondary; odd-n requires center-cell correction

Day 5: Greedy Algorithm

  • Max digit = bottleneck (deci-binary)
  • Pair opposites for minimization
  • Balance tracking for greedy splits
  • Sorting for optimal assignment
  • Digit placement strategy
  • Bucketing + greedy filling

Day 6: Hash-Based Counting

  • Streaming hash map for pair counting: ans += counts[x]; counts[x] += 1
  • Set membership for filter-preserving-order
  • Distinct-count collapse: max splits with distinct property = number of distinct elements

Day 8: Multi-Pattern Recovery Session (20 problems)

DP & Recurrences

  • DP / Fibonacci: two-variable rolling (prev2, prev1 = prev1, prev1 + prev2)
  • Bit Manipulation DP: ans[i] = ans[i>>1] + (i & 1) for popcount in O(n)
  • Memoization vs bottom-up: @lru_cache is plan B; bottom-up shows you understand dependency order

Bit Manipulation Toolkit

  • XOR + popcount template: popcount(a ^ b) counts differing bits — Hamming distance, min bit flips
  • OR-shift identity for subset XOR sum: answer = OR(nums) << (n-1) — half of all subsets have any given bit set
  • Bitmask as set: 26-bit integer = set of lowercase letters; (word_mask & ~allowed_mask) == 0 for subset check
  • Adjacent-pair operations: [a | b for a, b in zip(nums, nums[1:])] — generalizes to any pairwise op
  • Brian Kernighan trick: x &= x - 1 clears the lowest set bit; iteration count = popcount

Sorting & Greedy

  • Greedy pairing (LC 561): sort, take every even index for max sum-of-mins; exchange argument proves optimality
  • Counting sort: when value range is bounded (1..100), beats comparison sort at O(n + R)
  • Set intersection vs two-pointer: sets win on clarity, two-pointer wins on already-sorted input

Permutation & Frequency

  • Permutation frequency trick (LC 2657): when both arrays are permutations, freq[v] ≤ 2 → "v becomes common" = "freq hits 2"
  • Increment-then-check pattern: counter[key] += 1; if counter[key] == THRESHOLD: action()

Enumeration & Digit

  • Digit-symmetric trick: 2-digit symmetric numbers are exactly multiples of 11 in [11, 99]
  • String vs arithmetic digit extraction: str(x)[:half] generalizes; x // 1000 + x % 1000 // 100 is faster but case-specific

Matrix

  • Diagonals: odd-n center cell is on both diagonals → subtract once. (i,i) and (i, n-1-i) are canonical indices

Prefix Sum

  • Store-before-update pattern: record running sum BEFORE adding current element to exclude it from "left of i"
  • Total trick: rightSum = total - leftSum - nums[i] collapses two passes into one
  • In-place running sum: read previous (already-cumulative) cell to update current; no extra array needed
  • itertools.accumulate: Python's superpower for any associative reduction (sum, product, min, max, xor)

Simulation & In-Place Tricks

  • Bit-packing for O(1) space (LC 1920): cell = old + n*new; decode with % n and // n. Lets you store two values in one cell using base-n encoding
  • "Stateless map → sum" pattern: when each element transforms independently, sum(f(x) for x in items) replaces explicit loops
  • The "just a return" recognition: if there's no running state between iterations, list comprehension is the answer

SQL Patterns (4 new)

  • WHERE filter (LC 1821): simplest SQL primitive; watch for "positive" = > 0 vs "non-negative" = >= 0
  • CROSS JOIN (LC 2339): CROSS JOIN ... WHERE t1.x != t2.x for all ordered pairs; < for unordered
  • GROUP BY + COUNT DISTINCT (LC 2356): dedupe BEFORE counting; foundational analytics idiom
  • Anti-join (LC 2084): three idioms — NOT EXISTS, NOT IN, LEFT JOIN ... IS NULL. Window function MIN(x) OVER (PARTITION BY group) is the elegant alternative for "keep best per group"

Day 9: Strings + Tree DFS Toolkit (10 problems)

String / Pairwise Aggregation

  • Adjacent-pair template (LC 3110): sum(op(a, b) for a, b in zip(seq, seq[1:])) — same skeleton as yesterday's LC 3173, now with abs(ord(a) - ord(b)) as the op. The template handles sum/max/list of any pairwise computation.
  • Score as "total variation" — sum of absolute differences across consecutive elements; the same metric used in signal processing and time-series analysis.

String / Filtering

  • Filter pattern (LC 1119): ''.join(c for c in s if predicate(c)). Three implementations: generator + join, hash set lookup, or str.translate() for C-level speed on long inputs.
  • Critical Python habit: NEVER use += in a loop to build a string — it's O(n²) due to string immutability. Always use list.append + ''.join or a generator.

String / Indexed Iteration

  • enumerate (LC 2942): when you need BOTH index and value, enumerate(items) beats manual range(len(items)). The indexed-filter pattern: [i for i, x in enumerate(items) if predicate(x)] — distinct from a plain filter that returns values.

String / 2D Coordinates

  • Manhattan distance + position lookup (LC 3846): build a char → (row, col) dict ONCE, then it's O(1) per query. For sequences with implicit starting state, either prepend the start OR maintain explicit running state.
  • Connection to LC 3110: Manhattan distance is the 2D version of abs(ord(a) - ord(b)). Same adjacent-pair skeleton, two dimensions instead of one.

String / Prefix Sum / Two-Pass Sweep

  • Two-pass directional sweep (LC 1769): decompose "sum over all pairs" into separate left-side and right-side contributions. The running update trick: cost += balls per step (every existing ball gets +1 distance as cursor moves).
  • Same skeleton as yesterday's LC 2574 — only the aggregation function changed (absolute differences instead of subtraction).

Tree DFS — The Four Flavors

  • DFS to produce a list (LC 94 Inorder): traverse Left → Node → Right; for BSTs this gives sorted output. Iterative version uses explicit stack — required for tree iterator implementations (LC 173 BST Iterator).
  • DFS to compare two trees (LC 100 Same Tree): parallel recursion with three base cases: both None (match), one None (mismatch), both exist (compare + recurse). Skeleton extends to LC 101 Symmetric, LC 572 Subtree.
  • DFS to aggregate a value (LC 104 Max Depth): divide-and-conquer skeleton 1 + max(L, R). Change the combine function and you solve dozens of tree problems: count nodes (1 + L + R), sum values (val + L + R), path sum, balance check.
  • DFS to mutate the tree (LC 226 Invert): swap children at every node. When each node's work is independent of others, traversal order is free — any DFS or BFS works. Python's tuple-swap node.left, node.right = node.right, node.left is the safe simultaneous-assignment idiom.

Tree DFS — Composition (Medium)

  • Two-phase pattern (LC 1382 Balance BST): Phase 1 inorder → sorted array (uses BST property). Phase 2 recursive build picking middle as root (same divide-and-conquer as binary search). This problem = LC 94 + LC 108 composed. Recognizing pattern composition is the Medium-tier insight.
  • Overflow-safe middle formula: start + (end - start) // 2 instead of (start + end) // 2. Doesn't matter in Python (unbounded ints) but mandatory in C++/Java.

Debugging Lessons (from real session bugs)

  • Method name consistency: if you misspell the definition (creat_balanced_bst) but call it correctly (create_balanced_bst), Python's "Did you mean?" error suggests the misspelled one. Always check both directions.
  • Copy-paste typo on root.left vs root.right: common when typing inorder traversal — the third recursion is root.right, NOT a copy of the first line. Watch for this.
  • Sign flip in math formulas: (end - start) vs (end + start) — accidentally works for start=0 but breaks for non-zero starts, producing out-of-range indices.

📚 Notes

Each problem file includes:

  • ✅ Understanding the Goal
  • ✅ LAYER 1: Line-by-line code explanation (with heavy inline comments)
  • ✅ LAYER 2: Worked examples with traces
  • ✅ LAYER 3: Key insights & complexity
  • ✅ LAYER 4: Interview variations
  • ✅ LAYER 5: Cheat sheet entry

Patterns Cheat Sheet: See notes/patterns.md


Last Updated: June 5, 2026 | 71 Problems Solved ✅

Next: W3 — Sliding Window & Stack (Medium-difficulty pattern drill); plan to add review days for already-solved problems

About

Record daily study log of leetcode study & coding test

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors