Array
LeetCode 3904: Smallest Stable Index II
·1 min
LeetCode
Medium
Prefix-Sum
Array
LeetCode 3904 note: the first index where the prefix maximum minus the suffix minimum is <= k; build the suffix minimum right to left first
LeetCode 3903: Smallest Stable Index I
·1 min
LeetCode
Easy
Prefix-Sum
Array
LeetCode 3903 note: the first index where the prefix maximum minus the suffix minimum is <= k; build the suffix minimum right to left first
LeetCode 3898: Find the Degree of Each Vertex
·1 min
LeetCode
Easy
Graph
Matrix
Array
LeetCode 3898 note: the number of ones in row i of the adjacency matrix is vertex i’s degree
LeetCode 522: Longest Uncommon Subsequence II
·2 mins
LeetCode
Medium
Two-Pointers
String
Sorting
Array
Hash-Table
LeetCode 522 note: the longest uncommon subsequence is always a whole string; check strings from longest to shortest, and the first that is not a subsequence of any other long-enough string is the answer
LeetCode 1826: Faulty Sensor
·2 mins
LeetCode
Easy
Two-Pointers
Array
LeetCode 1826 note: at the first mismatch, test both “who dropped a value” explanations; if both fit, it cannot be determined, so return -1
LeetCode 3843: First Element with Unique Frequency
·1 min
LeetCode
Medium
Hash-Table
Counting
Array
LeetCode 3843 note: count each value, then count how many values share each count; the first element from the left whose count is its own is the answer
LeetCode 3842: Toggle Light Bulbs
·1 min
LeetCode
Easy
Hash-Table
Simulation
Array
LeetCode 3842 note: toggle membership in a set, or keep bulbs appearing an odd number of times, then sort
LeetCode 3840: House Robber V
·2 mins
LeetCode
Medium
Dynamic-Programming
Array
LeetCode 3840 note: houses conflict only when adjacent with the same color; take a house outright when the colors differ, and do the House Robber choice only when they match
LeetCode 3838: Weighted Word Mapping
·1 min
LeetCode
Easy
Array
String
Simulation
LeetCode 3838 note: sum each word’s letter weights mod 26 and map backward: 0 -> z, i.e. chr(ord(‘z’) - r)
LeetCode 3719: Longest Balanced Subarray I
·2 mins
LeetCode
Medium
Hash-Table
Prefix-Sum
Segment-Tree
Array
LeetCode 3719 note: n is only 1500, so fix the left end and extend right, maintaining distinct odds and evens in two sets
LeetCode 1570: Dot Product of Two Sparse Vectors
·2 mins
LeetCode
Medium
Two-Pointers
Design
Hash-Table
Array
LeetCode 1570 note: store only non-zero (index, value) pairs, and compute the dot product by merging the two index-sorted lists with two pointers, multiplying only on equal indices
LeetCode 1229: Meeting Scheduler
·2 mins
LeetCode
Medium
Two-Pointers
Sorting
Array
LeetCode 1229 note: sort both people’s slots, then find intersections with two pointers as in 986; the first intersection that is long enough is the earliest slot