dsa1 min read
Missing Number [Medium] — Math Sum / XOR Trick
Find the missing number in [0..n] using the Gauss sum formula or XOR in O(n) time O(1) space.
Read →
1575 articles
Find the missing number in [0..n] using the Gauss sum formula or XOR in O(n) time O(1) space.
Find all elements appearing more than n/3 times using Extended Boyer-Moore Voting with two candidate trackers.
Rearrange an array so nums[0] `<` nums[1] > nums[2] `<` nums[3]... using virtual index mapping and nth_element for O(n) time.
Compress a sorted unique integer array into the smallest sorted list of range coverage strings.
Distribute minimum candies so each child with higher rating than neighbors gets more, using left-to-right then right-to-left passes.