add new solutions

This commit is contained in:
Yiyang Kang 2026-02-01 14:56:08 +09:00
parent 67cad91898
commit 51975f3386
Signed by: kkyy
SSH key fingerprint: SHA256:lJSbAzC3MvrSORdvIVK6h/3g+rVKJNzM7zq0MgA9WKY
24 changed files with 933 additions and 14 deletions

View file

@ -0,0 +1,18 @@
package q1475
func finalPrices(prices []int) []int {
st := make([]int, 0, 1024)
for i := len(prices) - 1; i >= 0; i-- {
p := prices[i]
for ; len(st) > 0 && st[len(st)-1] > p; st = st[:len(st)-1] {
}
if len(st) > 0 {
prices[i] = p - st[len(st)-1]
}
st = append(st, p)
}
return prices
}
var _ = finalPrices