题目
思路
- 单调栈
代码
每日温度public int[] dailyTemperatures(int[] T) {Stack<Integer> st = new Stack<>();int[] res = new int[T.length];for (int i = 0, j = 0; i < T.length; i++) {while (!st.isEmpty() && T[st.peek()] < T[i]) {int index = st.pop();res[index] = i - index;}st.push(i);}return res;}
