↓Skip to main content

LeetCode

LeetCode 1486: XOR Operation in an Array
·1 min
LeetCode Easy Math Bit-Manipulation
LeetCode 1486 note: generate start + 2i by definition and XOR them together
LeetCode 2469: Convert the Temperature
·1 min
LeetCode Easy Math
LeetCode 2469 note: apply the formulas directly, Kelvin = C + 273.15 and Fahrenheit = C × 1.8 + 32
LeetCode 2413: Smallest Even Multiple
·1 min
LeetCode Easy Math Number-Theory
LeetCode 2413 note: lcm(2, n), which is n when n is even and 2n when odd
LeetCode 2236: Root Equals Sum of Children
·1 min
LeetCode Easy Tree Binary-Tree
LeetCode 2236 note: a warm-up, plus practice with C++ pointer access
LeetCode 2235: Add Two Integers
·1 min
LeetCode Easy Math
LeetCode 2235 note: return the sum; the C++ version once failed to compile from a missing semicolon
LeetCode 3750: Minimum Number of Flips to Reverse Binary String
·2 mins
LeetCode Easy Two-Pointers Bit-Manipulation String
LeetCode 3750 note: compare the binary string with its reverse bit by bit; the number of mismatches is the answer
LeetCode 3731: Find Missing Elements
·1 min
LeetCode Easy Hash-Table Sorting Array
LeetCode 3731 note: the minimum and maximum are still present, so check every integer in between against a set
LeetCode 3712: Sum of Elements With Frequency Divisible by K
·1 min
LeetCode Easy Hash-Table Counting Array
LeetCode 3712 note: count each value, and for counts divisible by k add value × count
LeetCode 3709: Design Exam Scores Tracker
·2 mins
LeetCode Medium Binary-Search Prefix-Sum Design
LeetCode 3709 note: times are increasing, so store prefix sums and answer queries with two bisects; always parenthesize mid
LeetCode 3708: Longest Fibonacci Subarray
·1 min
LeetCode Medium Array
LeetCode 3708 note: lengths 1 and 2 always work; from the third element, extend while nums[i] == nums[i-1] + nums[i-2], otherwise reset to 2
LeetCode 3707: Equal Score Substrings
·2 mins
LeetCode Easy Prefix-Sum String
LeetCode 3707 note: accumulate the left score while scanning, with the right side as total minus left; scores are alphabet positions 1 to 26, not ord
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