We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 24c34fb commit f09e746Copy full SHA for f09e746
Arrays/739_Daily_Temperatures.java
@@ -0,0 +1,17 @@
1
+class Solution {
2
+ public int[] dailyTemperatures(int[] T) {
3
+ Stack<Integer> stk = new Stack<>();
4
+ int[] result = new int[T.length];
5
+
6
+ for (int i = 0; i < T.length; i++) {
7
+ while (!stk.isEmpty() && T[i] > T[stk.peek()]) {
8
+ int idx = stk.pop();
9
+ result[idx] = i - idx;
10
+ }
11
12
+ stk.push(i);
13
14
15
+ return result;
16
17
+}
0 commit comments