Final Prices With a Special Discount in a Shop
Given an array prices where prices[i] is the price of a given product, implement a function finalPrices to get the final price of each product. The final price is the price after applying the special discount for every product i where j is the minimum index satisfying j > i and prices[j] <= prices[i]. If there is no such index, the final price is prices[i] itself.
Ada AI
I want to discuss a solution
Help me solve this
Give more examples
What's wrong with my code?
How to use 'for loop' in javascript?
javascript (node 13.12.0)