We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0339eb2 commit 23c3db5Copy full SHA for 23c3db5
1 file changed
박예진/5주차/260127.cpp
@@ -0,0 +1,18 @@
1
+class Solution {
2
+public:
3
+ vector<int> dailyTemperatures(vector<int>& temperatures) {
4
+ stack<int> s; // idx
5
+ int n = temperatures.size();
6
+ vector<int> ans(n, 0);
7
+
8
+ for(int i = 0; i < temperatures.size(); i++){
9
+ while(!s.empty() && temperatures[s.top()] < temperatures[i]) {
10
+ int prev = s.top();
11
+ s.pop();
12
+ ans[prev] = i - prev;
13
+ }
14
+ s.push(i);
15
16
+ return ans;
17
18
+};
0 commit comments