Greedy
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
LeetCode 3689: Maximum Total Subarray Value I
·1 min
LeetCode
Medium
Greedy
Array
LeetCode 3689 note: the same subarray may be chosen repeatedly, and the whole array’s max minus min is the best single value, so choose it k times
LeetCode 2294: Partition Array Such That Maximum Difference Is K
·1 min
LeetCode
Medium
Greedy
Sorting
Array
LeetCode 2294 note: subsequences ignore order, so sort and extend each group from its minimum until a value exceeds min + k
LeetCode 2131: Longest Palindrome by Concatenating Two Letter Words
·2 mins
LeetCode
Medium
Greedy
Hash-Table
String
Counting
LeetCode 2131 note: pair each word with its reverse on both sides; self-palindromes also pair with each other, and only one leftover can sit in the middle
LeetCode 853: Car Fleet
·2 mins
LeetCode
Daily
Medium
Array
Stack
Greedy
Simulation
Sorting
Solving the Car Fleet problem using stack-based approach
LeetCode 135: Candy
·2 mins
LeetCode
Hard
Greedy
Array
LeetCode 135 note: one pass left to right for the left neighbor, one right to left for the right neighbor, and give each child the larger of the two
LeetCode 3638: Maximum Balanced Shipments
·2 mins
LeetCode
Medium
Dynamic-Programming
Greedy
Monotonic-Stack
Array
LeetCode 3638 note: greedily cut a segment as soon as a value below its maximum appears; until then the segment is non-decreasing, so its maximum is the previous value
LeetCode 3627: Maximum Median Sum of Subsequences of Size 3
·2 mins
LeetCode
Medium
Math
Greedy
Sorting
Game-Theory
Array
LeetCode 3627 note: after sorting, each group takes the two largest and the smallest, with the second largest as the median; the answer takes every other value from the end, n / 3 of them
LeetCode 2745: Construct the Longest New String
·2 mins
LeetCode
Medium
Dynamic-Programming
Math
Greedy
Brainteaser
LeetCode 2745 note: AA and BB must alternate, using min(x, y) pairs plus one extra of the more common kind, and every AB fits in
LeetCode 2410: Maximum Matching of Players With Trainers
·2 mins
LeetCode
Medium
Two-Pointers
Greedy
Sorting
Array
LeetCode 2410 note: sort both sides, then same-direction pointers match the weakest player with the smallest trainer that is good enough
LeetCode 1353: Maximum Number of Events That Can Be Attended
·2 mins
LeetCode
Medium
Heap
Greedy
Sorting
LeetCode 1353 note: each day, attend the event that ends earliest, using a min-heap of end days
LeetCode 3572: Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values
·2 mins
LeetCode
Medium
Greedy
Hash-Map
Sorting
LeetCode 3572 note: keep the largest y for each x, then take the three largest