1、确定单调栈的递增/递减方向2、每次移动保证当前值与栈顶数据的实时更新递增方向: 当遍历元素小于或等于栈顶元素时,入栈,调整栈顶元素为最新移入的最小值,依次遍历,当获取大值时,出栈顶,计算差值,直到栈顶元素大于遍历当前元素最新值,最新值入栈,重复此过程,直到遍历完成 function dailyTemperatures(temperatures: number[]): number[] { const result = new Array(temperatures.length).fill(0), st = [0]; for(let i = 1; i < temperatures.length; i++) { if(temperatures[i] <= temperatures[st[st.length - 1]]) { st.push(i); } else { while(st.length >0 && temperatures[i] > t
李优秀同学
待会去码头整点薯条