Medium
LeetCode 3919: Minimum Cost to Move Between Indices
·2 mins
LeetCode
Medium
Greedy
Prefix-Sum
Array
LeetCode 3919 note: walk one step at a time, each costing 1 (when the next index is the closest) or the gap; jumping is never cheaper, so answer queries with prefix sums
LeetCode 3918: Sum of Primes Between Number and Its Reverse
·2 mins
LeetCode
Medium
Math
Number-Theory
LeetCode 3918 note: reverse n, take the range [min, max], and sum primes by trial division; test divisibility with %, never by comparing // with /
LeetCode 377: Combination Sum IV
·3 mins
LeetCode
Medium
Dynamic-Programming
Unbounded-Knapsack
LeetCode note for Combination Sum IV, rebuilt from the original learning note
LeetCode 279: Perfect Squares
·3 mins
LeetCode
Medium
Dynamic-Programming
LeetCode note for Perfect Squares, rebuilt from the original learning note
LeetCode 743: Network Delay Time
·3 mins
LeetCode
Medium
Graph
Dijkstra
Shortest-Path
LeetCode note for Network Delay Time, rebuilt from the original learning note
LeetCode 55: Jump Game
·2 mins
LeetCode
Medium
Greedy
LeetCode note for Jump Game, rebuilt from the original learning note
LeetCode 45: Jump Game II
·3 mins
LeetCode
Medium
Greedy
Bfs
LeetCode note for Jump Game II, rebuilt from the original learning note
LeetCode 300: Longest Increasing Subsequence
·3 mins
LeetCode
Medium
Dynamic-Programming
Binary-Search
LeetCode note for Longest Increasing Subsequence, rebuilt from the original learning note
LeetCode 152: Maximum Product Subarray
·3 mins
LeetCode
Medium
Dynamic-Programming
LeetCode note for Maximum Product Subarray, rebuilt from the original learning note
LeetCode 281: Zigzag Iterator
·2 mins
LeetCode
Medium
Queue
Design
Iterator
LeetCode 281 note: a queue of unfinished sources, take one value in turn and put the source back if anything remains; it generalizes to k sources
LeetCode 1059: All Paths from Source Lead to Destination
·2 mins
LeetCode
Medium
Graph
Topological-Sort
LeetCode 1059 note: trim outdegrees backward from the destination; a node is safe only when every outgoing edge leads to a safe node, and the destination itself must have no outgoing edges
LeetCode 91: Decode Ways
·3 mins
LeetCode
Medium
Dynamic-Programming
String
LeetCode note for Decode Ways, rebuilt from the original learning note