↓Skip to main content

LeetCode

LeetCode 2328: Number of Increasing Paths in a Grid
·2 mins
LeetCode Hard Dynamic-Programming Grid-Dp Memoization Topological-Sort Matrix
LeetCode 2328 note: strictly increasing means no cycles; dp[cell] = 1 + Σ dp[larger neighbors], processed from largest to smallest value (or by memoized DFS), summed over all cells
LeetCode 1377: Frog Position After T Seconds
·3 mins
LeetCode Hard Tree Dfs Bfs Graph Probability
LeetCode 1377 note: undirected edges, seen must hold nodes, and an early arrival depends on whether the frog can still move
LeetCode 1292: Maximum Side Length of a Square with Sum Less than or Equal to Threshold
·3 mins
LeetCode Medium Binary-Search Prefix-Sum Matrix
LeetCode 1292 note: 2D prefix sums plus binary search on the side length; never mix the two binary search styles
LeetCode 1178: Number of Valid Words for Each Puzzle
·3 mins
LeetCode Hard Bit-Manipulation Hash-Map Trie
LeetCode 1178 note: a word only matters by its set of letters, so count 26-bit masks and enumerate each puzzle’s submasks
LeetCode 2585: Number of Ways to Earn Points
·2 mins
LeetCode Hard Dynamic-Programming Knapsack Array
LeetCode 2585 note: a bounded (grouped) knapsack; each question type takes 0 to count questions, with capacity running backwards and the count enumerated inside
LeetCode 410: Split Array Largest Sum
·2 mins
LeetCode Hard Dynamic-Programming Binary-Search Greedy Prefix-Sum Array
LeetCode 410 note: binary search the answer; for a cap mid, greedily fill each segment to count the fewest segments, and mid works if that count is <= k
LeetCode 4026: Maximum Gap Between Stations
·2 mins
LeetCode Medium Two-Pointers Greedy String
LeetCode 4026 note: greedily match from the left for each worker’s earliest station and from the right for the latest; splitting between workers i and i+1, the largest gap is latest[i+1] - earliest[i]
LeetCode 1320: Minimum Distance to Type a Word Using Two Fingers
·2 mins
LeetCode Hard Dynamic-Programming State-Machine String
LeetCode 1320 note: after typing word[i], one finger is always on word[i], so the state is only the other finger’s position; dp[other] is the least distance with the other finger at other
LeetCode 3895: Count Digit Appearances
·1 min
LeetCode Medium Math Array
LeetCode 3895 note: convert each number to a string and add up how many times the digit appears
LeetCode 518: Coin Change 2
·3 mins
LeetCode Medium Dynamic-Programming Unbounded-Knapsack
LeetCode note for Coin Change 2, rebuilt from the original learning note
LeetCode 494: Target Sum
·3 mins
LeetCode Medium Dynamic-Programming Knapsack Subset-Sum
LeetCode note for Target Sum, rebuilt from the original learning note
LeetCode 416: Partition Equal Subset Sum
·3 mins
LeetCode Medium Dynamic-Programming Knapsack Subset-Sum
LeetCode note for Partition Equal Subset Sum, rebuilt from the original learning note