LeetCode --- 1475. Final Prices With a Special Discount in a Shop 解题报告

Posted 杨鑫newlfe

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode --- 1475. Final Prices With a Special Discount in a Shop 解题报告相关的知识,希望对你有一定的参考价值。

You are given an integer 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 integer array answer where answer[i] is the final price you will pay for the ith item of the shop, considering the special discount.

Example 1:

Input: prices = [8,4,6,2,3]
Output: [4,2,4,2,3]
Explanation: 
For item 0 with price[0]=8 you will receive a discount equivalent to prices[1]=4, therefore, the final price you will pay is 8 - 4 = 4.
For item 1 w

以上是关于LeetCode --- 1475. Final Prices With a Special Discount in a Shop 解题报告的主要内容,如果未能解决你的问题,请参考以下文章

Leetcode 1475. Final Prices With a Special Discount in a Shop

LeetCode 1475 商品折扣后的最终价格[栈] HERODING的LeetCode之路

LeetCode 1475. 商品折扣后的最终价格 / 687. 最长同值路径 / 652. 寻找重复的子树

LeetCode 1475. 商品折扣后的最终价格 / 687. 最长同值路径 / 652. 寻找重复的子树

LeetCode9月 每日一题

LeetCode9月 每日一题