Company: Amazon_1march
Difficulty: medium
In an Amazon warehouse, there are n orders to be processed, each with a priority represented by an array priorities , where priorities[i] denotes the priority of the i th order. Orders are processed in reverse, starting from the last order (index n - 1 ) and moving to the first order (index 0). An order experiences "delay" if an order with lower priority is processed before it. The delay period for an order starts when the first lower-priority order begins processing and ends when the order itself is finally being processed. Given that each order takes 1 unit of time to process, calculate the delay time for each order. Example: n = 4, priorities = [8, 2, 5, 3] The orders are processed in reverse, starting from the last order and moving to the first: Order 3 (priority 3): No prior orders processed, so delay = 0. Order 2 (priority 5): First lower-priority order processed before it is Order 3 (priority 3), so the delay for order 2 is the difference in their positions (since each order tak