dsa1 min read
Find Peak Element [Medium] — Binary Search on Slope
Find a peak element in O(log n) by binary searching on the slope direction — always move toward the higher neighbor.
Read →
webcoderspeed.com
1276 articles
Find a peak element in O(log n) by binary searching on the slope direction — always move toward the higher neighbor.
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.