LeetCode
LeetCode 3090: Maximum Length Substring With Two Occurrences
·1 min
LeetCode
Easy
Sliding-Window
Hash-Table
String
LeetCode 3090 note: a longest-window slide that shrinks the left whenever the newly added character appears more than twice
LeetCode 2958: Length of Longest Subarray With at Most K Frequency
·1 min
LeetCode
Medium
Sliding-Window
Hash-Table
Array
LeetCode 2958 note: a longest-window slide that shrinks the left whenever the newly added number appears more than k times
LeetCode 220: Contains Duplicate III
·3 mins
LeetCode
Hard
Sliding-Window
Bucket-Sort
Ordered-Set
Sorting
Array
LeetCode 220 note: with bucket size valueDiff + 1, two numbers in one bucket always qualify, so only the two neighboring buckets need checking; the window keeps the latest indexDiff numbers, so each bucket holds at most one
LeetCode 2024: Maximize the Confusion of an Exam
·2 mins
LeetCode
Medium
Sliding-Window
String
Binary-Search
Prefix-Sum
LeetCode 2024 note: a window is valid when the rarer of T and F appears at most k times (flip all of them); shrink the left when it is not
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