We’re preparing your current view and syncing the latest data.
You are given an array prices where prices[i] is the price of the ith item in a shop. There is a special discount for items in the shop. If you buy the ith item, then you will receive a discount equivalent to prices[j] where j is the minimum index such that j > i and prices[j] <= prices[i]. Otherwise, you will not receive any discount at all. Return an array where the ith element is the final price you will pay for the ith item of the shop, taking into account the discount.
An array prices of integers representing the price of each item.
An array of integers representing the final price you will pay for each item after subtracting the discount if applicable.
1 <= prices.length <= 500 1 <= prices[i] <= 1000