Medium
LeetCode 394: Decode String
·2 mins
LeetCode
Medium
Stack
String
Recursion
LeetCode 394 note: on [ push the current string and count, on ] pop and combine; counts can have several digits
LeetCode 2300: Successful Pairs of Spells and Potions
·2 mins
LeetCode
Medium
Binary-Search
Sorting
Two-Pointers
LeetCode 2300 note: sort potions, bisect a threshold per spell, and compute the threshold with integer ceil to avoid float error
LeetCode 3703: Remove K-Balanced Substrings
·2 mins
LeetCode
Medium
Stack
String
Simulation
LeetCode 3703 note: repeated replace is O(n^2); a stack of (character, run length) removes k ( plus k ) as soon as they line up
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 1493: Longest Subarray of 1's After Deleting One Element
·2 mins
LeetCode
Medium
Sliding-Window
Dynamic-Programming
Array
LeetCode 1493 note: find the longest window with at most one 0; since one element must be deleted, the answer is the window length minus 1
LeetCode 3195: Find the Minimum Area to Cover All Ones I
·1 min
LeetCode
Medium
Array
Matrix
LeetCode 3195 note: track the topmost, bottommost, leftmost and rightmost 1; the area is height times width
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 3649: Number of Perfect Pairs
·2 mins
LeetCode
Medium
Two-Pointers
Math
Sorting
Array
LeetCode 3649 note: simplify the condition to “larger absolute value <= 2 × smaller absolute value”, then count with two pointers over sorted absolute values
LeetCode 3648: Minimum Sensors to Cover Grid
·2 mins
LeetCode
Medium
Math
LeetCode 3648 note: each sensor covers a (2k + 1) × (2k + 1) square, so take a ceiling division in each direction and multiply
LeetCode 901: Online Stock Span
·2 mins
LeetCode
Daily
Medium
Stack
Monotonic-Stack
Data-Structures
Design
Design-Patterns
Stock
Solving the Online Stock Span problem using monotonic stack approach
LeetCode 853: Car Fleet
·2 mins
LeetCode
Daily
Medium
Array
Stack
Greedy
Simulation
Sorting
Solving the Car Fleet problem using stack-based approach