This is the similar problem with: https://www.cnblogs.com/feiflytech/p/16169025.html
class Solution { public int[] dailyTemperatures(int[] t) { int[] res = new int[t.length]; Stack<Integer> stk = new Stack<>(); for(int i=0;i<t.length;i++){ while(!stk.isEmpty() && t[i]>t[stk.peek()]){ int index = stk.pop(); res[index]=i-index; } stk.push(i); } return res; } }