↓Skip to main content

LeetCode

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
LeetCode 139: Word Break
·2 mins
LeetCode Medium Dynamic-Programming String
LeetCode note for Word Break, rebuilt from the original learning note
LeetCode 3914: Minimum Operations to Make Array Non Decreasing
·2 mins
LeetCode Medium Greedy Array
LeetCode 3914 note: adding x to a range raises only the difference at its left edge by x, so the answer is the sum of all drops
LeetCode 3913: Sort Vowels by Frequency
·2 mins
LeetCode Medium String Sorting Counting
LeetCode 3913 note: extract only the vowels, sort by (-count, first occurrence), and put them back into the vowel positions
LeetCode 3912: Valid Elements in an Array
·2 mins
LeetCode Easy Array
LeetCode 3912 note: greater than all on the left means greater than the prefix maximum, and likewise for the right with the suffix maximum; scan both ways and output in original order
LeetCode 3910: Count Connected Subgraphs with Even Node Sum
·3 mins
LeetCode Hard Bit-Manipulation Enumeration Graph Union-Find
LeetCode 3910 note: n is tiny, so enumerate subsets with a bitmask, check the even sum first, then check that the induced subgraph is connected
LeetCode 269: Alien Dictionary
·3 mins
LeetCode Hard Graph Topological-Sort
LeetCode note for Alien Dictionary, rebuilt from the original learning note
LeetCode 787: Cheapest Flights Within K Stops
·3 mins
LeetCode Medium Graph Bellman-Ford Shortest-Path
LeetCode note for Cheapest Flights Within K Stops, rebuilt from the original learning note
LeetCode 746: Min Cost Climbing Stairs
·2 mins
LeetCode Easy Dynamic-Programming
LeetCode note for Min Cost Climbing Stairs, rebuilt from the original learning note
LeetCode 740: Delete and Earn
·2 mins
LeetCode Medium Dynamic-Programming
LeetCode note for Delete and Earn, rebuilt from the original learning note