C# 代码
public class Solution {
public int[] DailyTemperatures(int[] temperatures) {
int n = temperatures.Length;
int[] result = new int[n];
Stack<int> stack = new Stack<int>();
for (int i = 0; i < n; i++){
while (stack.Count > 0 && temperatures[stack.Peek()] < temperatures[i]){
int t = stack.Pop();
result[t] = i - t;
}
stack.Push(i);
}
return result;
}
}