Given a list of daily temperaturesContinue reading “[Leetcode]739. Daily Temperatures”T
, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put0
instead. For example, given the list of temperaturesT = [73, 74, 75, 71, 69, 72, 76, 73]
, your output should be[1, 1, 4, 2, 1, 1, 0, 0]
. Note: The length oftemperatures
will be in the range[1, 30000]
. Each temperature will be an integer in the range[30, 100]
.
[Leetcode problems]1475. Final Prices With a Special Discount in a Shop
Given the arrayContinue reading “[Leetcode problems]1475. Final Prices With a Special Discount in a Shop”prices
whereprices[i]
is the price of theith
item in a shop. There is a special discount for items in the shop, if you buy theith
item, then you will receive a discount equivalent toprices[j]
wherej
is the minimum index such thatj > i
andprices[j] <= prices[i]
, otherwise, you will not receive any discount at all. Return an array where theith
element is the final price you will pay for theith
item of the shop considering the special discount. Examples: Input: prices = [8,4,6,2,3] Output: [4,2,4,2,3] Input: prices = [1,2,3,4,5] Output: [1,2,3,4,5]