Jim and the Orders

Published by Edward Clark in

Jim's Burgers has a line of hungry customers. Orders vary in the time it takes to prepare them. Determine the order the customers receive their orders. Start by numbering each of the customers from 1 to n, front of the line to the back. You will then be given an order number and a preparation time for each customer.

The time of delivery is calculated as the sum of the order number and the preparation time. If two orders are delivered at the same time, assume they are delivered in ascending customer number order.

For example n=5, there are customers in line. They each receive an order number order[i] and a preparation time prep[i]:

Customer12345
Order #85624
Prep time36233
Calculate:
Serve time1111857

We see that the orders are delivered to customers in the following order:

Serve time5781111
Customer45312

Your jimOrders method should return an array of integers that represent the order that customers' orders are delivered.

jimOrders has the following parameter(s):

  • orders: a 2D integer array where each orders[i] is in the form (order[i],prep[i]).

Video Description and Solution

Watch a quick demo on how Edabit works.