less than 1 minute read

You are given a list of non-negative integers prices representing the daily stock prices of a company in chronological order. Return a list of the same length where the value at index i is the minimum number of days you would have to wait until you make a profit. If there’s no way to make a profit the value should be 0.

Constraints

  • n ≤ 100,000 where n is the length of prices

https://binarysearch.com/problems/Wallstreet-Bets

Examples

Example 1

Input

  • prices = [3, 2, 4, 8, 6, 5]

Output

  • answer = [2, 1, 1, 0, 0, 0]

Solution

Categories:

Updated:

Leave a comment