Problem · Array

Return Priority of Order IDs

MediumDoorDashPHONE SCREEN

Given a list of ints representing order IDs, return the priority of the order IDs based on the values of their neighbors. An order is considered if it's greater than it's neighbors to the left and right of it.

Function Description

Complete the function getOrderPriorities in the editor.

getOrderPriorities has the following parameter:

  1. List orderIds: a list of integers representing order IDs

Returns

List: the priority of the order IDs

Examples
01 · Example 1
orderIds = [3, 5, 1, 4, 2]
return = [4, 2, 5, 3, 1]
If we iterate over [3, 5, 1, 4, 2], the order IDs that can be considered in this first pass is 5 and 4. In this case, remove 4 because it's the order ID with the smallest value. The result of the removal looks like this: [3, 5, 1, 2] If we iterate over [3, 5, 1, 2], the order IDs that can be considered in this pass is 5 and 2. In this case, remove 2 because it's the order ID with the smallest value. The result of the removal looks like this: [3, 5, 1] Continue on from there until the list is empty
More DoorDash problems
drafts saved locally
public List<Integer> getOrderPriorities(List<Integer> orderIds) {
  // write your code here
}
orderIds[3, 5, 1, 4, 2]
expected[4, 2, 5, 3, 1]
sign in to submit