LeetCode
LeetCode 3: Longest Substring Without Repeating Characters
·2 mins
LeetCode
Daily
Medium
Sliding-Window
Hash-Map
LeetCode Problem Solving
LeetCode 239: Sliding Window Maximum
·3 mins
LeetCode
Daily
Hard
Monotonic-Queue
LeetCode Problem Solving
LeetCode 2090: K Radius Subarray Averages
·2 mins
LeetCode
Daily
Medium
Sliding-Window
LeetCode Problem Solving
LeetCode 1343: Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold
·3 mins
LeetCode
Daily
Medium
Array
Sliding-Window
Prefix-Sum
Average-Calculation
LeetCode Problem Solving - Fixed Size Sliding Window with Sum Calculation
LeetCode 2874: Maximum Value of an Ordered Triplet II
·2 mins
LeetCode
Medium
Prefix-Sum
Array
LeetCode 2874 note: fix the middle j and take the prefix maximum on the left and the suffix maximum on the right, or scan once tracking the maximum and the best difference
LeetCode 1222: Queens That Can Attack the King
·2 mins
LeetCode
Medium
Array
Matrix
Simulation
LeetCode 1222 note: step outward from the king in eight directions; the first queen met in each direction can attack, with queens in a set for lookups
LeetCode 2044: Count Number of Maximum Bitwise-OR Subsets
·2 mins
LeetCode
Medium
Backtracking
Bit-Manipulation
Enumeration
LeetCode 2044 note: the maximum OR is the OR of everything; once backtracking reaches it, count the rest as 2^k
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 2210: Count Hills and Valleys in an Array
·1 min
LeetCode
Easy
Array
LeetCode 2210 note: treat equal neighbors as one point and remember only the last non-flat direction; up then down is a hill, down then up a valley
LeetCode 665: Non-decreasing Array
·2 mins
LeetCode
Medium
Array
LeetCode 665 note: at a drop, lower nums[i-1] when possible, and only when nums[i] < nums[i-2] raise nums[i] instead; a second drop fails
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 1248: Count Number of Nice Subarrays
·3 mins
LeetCode
Medium
Sliding-Window
Prefix-Sum
Hash-Table
Array
LeetCode 1248 note: “exactly k odd numbers” is not monotonic, so compute “at most k” minus “at most k - 1”; or use prefix sums with a hash map