Doordash TPS 1 - Software Engineer
Anonymous User
915
Jan 06, 2024
Jan 06, 2024
Given a list of order ids (strictly positive, unique), return the orders in the smallest eligible order.
An order is eligible if it's strictly greater than it's immediate left and right neighbors. If there are more than one orders that are eligible, the order with smaller id takes precedence.
Example: [2]
Result: [2]
Example: [2, 4]
Result: [4, 2]
Example: [1, 4, 2]
Result: [4, 2, 1]
Provide a solution that is better than O(n^2)
Comments (3)


