I've been exploring some algorithmic problems and I'm puzzled about the most efficient way to solve this particular question. While nested for loops are an option, they don't seem like the optimal choice. I'm considering using a hash map to keep track of the temperature and the index associated with it.
Imagine you have a list of daily temperatures. Your task is to create a new list that indicates, for each day in the input, how many days you would need to wait until a warmer temperature occurs. If there's no future day with a higher temperature, mark 0 instead. For instance, if the input list is temperatures = [73, 74, 75, 71, 69, 72, 76, 73], then your output should look like this: [1, 1, 4, 2, 1, 1, 0, 0].