Given an array of distinct elements, repeatedly find the smallest peak (an element greater than its neighbours), remove it, and return the sequence of removed peaks until the array is empty.
You've read your 3 free write-ups
Sign up free to keep reading. Your account opens the first 10 questions of every company.