【单调栈】
class Solution {
// 单调栈 10:18 42
public int[] dailyTemperatures(int[] temperatures) {
Deque<Integer> stack = new LinkedList();
int[] t = temperatures;
int n = t.length;
int[] ans = new int[n];
for (var i = n - 1; i >= 0; i--) {
while (!stack.isEmpty() && t[stack.peek()] <= t[i]) {
stack.pop();
}
if (stack.isEmpty()) {
ans[i] = 0;
} else {
ans[i] = stack.peek() - i;
}
stack.push(i);
}
return ans;
}
}