↓Skip to main content

Medium

LeetCode 1208: Get Equal Substrings Within Budget
·1 min
LeetCode Medium Sliding-Window String Binary-Search Prefix-Sum
LeetCode 1208 note: each position costs |s[i] - t[i]|, so the problem becomes the longest subarray with sum <= maxCost
LeetCode 865: Smallest Subtree with all the Deepest Nodes
·2 mins
LeetCode Medium Tree Binary-Tree Bfs Dfs Lca
LeetCode 865 note: BFS to the last level and climb together, or one DFS returning (depth, node)
LeetCode 1339: Maximum Product of Splitted Binary Tree
·2 mins
LeetCode Medium Tree Binary-Tree Dfs
LeetCode 1339 note: compute the total, enumerate every subtree sum, and leave the input untouched
LeetCode 1975: Maximum Matrix Sum
·2 mins
LeetCode Medium Greedy Matrix Array
LeetCode 1975 note: minus signs can travel anywhere in pairs but the parity of the negative count never changes; with an odd count, leave one on the smallest absolute value
LeetCode 1161: Maximum Level Sum of a Binary Tree
·2 mins
LeetCode Medium Tree Binary-Tree Bfs
LeetCode 1161 note: pushing None into the next level creates a fake level with sum 0
LeetCode 1461: Check If a String Contains All Binary Codes of Size K
·2 mins
LeetCode Medium Hash-Table String Bit-Manipulation Rolling-Hash
LeetCode 1461 note: put every length-k substring in a set and check that its size reaches 2^k; the last start is len(s) - k
LeetCode 1401: Circle and Rectangle Overlapping
·2 mins
LeetCode Medium Math Geometry
LeetCode 1401 note: the rectangle’s nearest point to the center is the center clamped into the rectangle; they overlap when that point is within the radius
LeetCode 1306: Jump Game III
·2 mins
LeetCode Medium Bfs Dfs Graph Array
LeetCode 1306 note: indices are nodes and the two jumps are edges; BFS or DFS decides whether a zero is reachable
LeetCode 3800: Minimum Cost to Make Two Binary Strings Equal
·2 mins
LeetCode Medium Greedy String
LeetCode 3800 note: split mismatches into two kinds; pair different kinds with a swap, same kinds with cross + swap, flip any leftover, and compare each against two flips
LeetCode 3799: Word Squares II
·2 mins
LeetCode Medium Backtracking Enumeration String
LeetCode 3799 note: four nested levels pruned by corner letters; sorting the words first makes the output lexicographic
LeetCode 1016: Binary String With Substrings Representing 1 To N
·3 mins
LeetCode Medium Sliding-Window String Bit-Manipulation Hash-Table
LeetCode 1016 note: s has at most 1000 characters, so there are few substrings of any fixed length and a large n must be False; checking from n downward fails fast, or extend up to 30 bits from each start to collect every value <= n
LeetCode 3796: Find Maximum Value in a Constrained Sequence
·2 mins
LeetCode Medium Greedy Array
LeetCode 3796 note: each position’s bound is the min of its own limit, the left bound + difference and the right bound + difference; one pass each way