Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0 instead.

&nbsp;
Example 1:
Input: temperatures = [73,74,75,71,69,72,76,73]
Output: [1,1,4,2,1,1,0,0]
Example 2:
Input: temperatures = [30,40,50,60]
Output: [1,1,1,0]
Example 3:
Input: temperatures = [30,60,90]
Output: [1,1,0]

&nbsp;
Constraints:


	1 &lt;=&nbsp;temperatures.length &lt;= 105
	30 &lt;=&nbsp;temperatures[i] &lt;= 100


class Solution:
    def dailyTemperatures(self, T):
        ans, s = [0]*len(T), deque()
        for cur, cur_tmp in enumerate(T):
            while s and cur_tmp > T[s[-1]]:
                ans[s[-1]] = cur - s[-1]
                s.pop()
            s.append(cur)
        return ans
class Solution {
    public int[] dailyTemperatures(int[] temperatures) {
        HashMap<Integer,Integer>hm=new HashMap<>();
        Stack<Integer>st=new Stack<>();
        for(int i=0;i<temperatures.length;i++){
            while(st.size()>0&&temperatures[i]>temperatures[st.peek()]){
                hm.put(st.pop(),i);
            }
            st.push(i);
        }
        int []ans=new int[temperatures.length];
        for(int i=0;i<temperatures.length;i++){
            if(hm.containsKey(i)){
                ans[i]=hm.get(i)-i;
            }else{
                ans[i]=0;
            }
        }
        return ans;
    }
}
class Solution {
public:
    vector<int> dailyTemperatures(vector<int>& temperatures) {
        int n = temperatures.size();
        stack<int> st;
        vector<int> result(n, 0);
        for(int i = 0; i<n; i++){
            while(!st.empty() && temperatures[i]>temperatures[st.top()]){
                result[st.top()] = i-st.top();
                st.pop();
            }
            st.push(i);
        }
        return result;
    }
};
var dailyTemperatures = function(temperatures) {
    const len = temperatures.length;
    const res = new Array(len).fill(0);
    const stack = [];
    
    for (let i = 0; i < len; i++) {
        const temp = temperatures[i];
        
        while (temp > (stack[stack.length - 1] || [Infinity])[0]) {
            const [_, j]  = stack.pop();
            res[j] = i - j;
        }
        
        stack.push([temp, i]);
    }
    
    return res;
};
Daily Temperatures