739. Daily Temperatures Medium

@problem@discussion
#Array#Stack#Monotonic Stack



1/**
2 * [739] Daily Temperatures
3 *
4 * 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 i^th day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0 instead.
5 *  
6 * Example 1:
7 * Input: temperatures = [73,74,75,71,69,72,76,73]
8 * Output: [1,1,4,2,1,1,0,0]
9 * Example 2:
10 * Input: temperatures = [30,40,50,60]
11 * Output: [1,1,1,0]
12 * Example 3:
13 * Input: temperatures = [30,60,90]
14 * Output: [1,1,0]
15 *  
16 * Constraints:
17 * 
18 * 	1 <= temperatures.length <= 10^5
19 * 	30 <= temperatures[i] <= 100
20 * 
21 */
22pub struct Solution {}
23
24// problem: https://leetcode.com/problems/daily-temperatures/
25// discuss: https://leetcode.com/problems/daily-temperatures/discuss/?currentPage=1&orderBy=most_votes&query=
26
27// submission codes start here
28
29impl Solution {
30    pub fn daily_temperatures(temperatures: Vec<i32>) -> Vec<i32> {
31        vec![]
32    }
33}
34
35// submission codes end
36
37#[cfg(test)]
38mod tests {
39    use super::*;
40
41    #[test]
42    fn test_739() {
43    }
44}
45


Back
© 2025 bowen.ge All Rights Reserved.