Back to problems

Find Eligible Order Sequence

Algorithm · DoorDash · Medium

A chef handles restaurant orders one at a time. The orders are given as an array of distinct integers called orderIds; after an order is handled, it is deleted from the array. An order is eligible when it is larger than every neighbor it currently has: At the beginning of the array, it must exceed the element immediately to its right. At the end of the array, it must exceed the element immediately to its left. Anywhere else, it must exceed both adjacent elements. Whenever…

Checking your access…