daily-temperatures
1.0.0
Daily Temperatures
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1
#include <bits/stdc++.h>
2
3
using namespace
std;
4
5
class
Solution
6
{
7
public
:
8
vector<int>
dailyTemperatures
(vector<int>& temperatures)
9
{
10
stack<int> temp_ind;
// temperature indices - monotonic stack
11
int
size = (int)temperatures.size();
12
vector<int> days(size, 0);
13
for
(
int
i = 0; i < size; ++i)
14
{
15
while
(!temp_ind.empty() && temperatures[i] > temperatures[temp_ind.top()])
16
{
17
days[temp_ind.top()] = i - temp_ind.top();
18
temp_ind.pop();
19
}
20
temp_ind.push(i);
21
}
22
return
days;
23
}
24
};
25
26
int
main
()
27
{
28
29
return
0;
30
}
Solution
Definition
main.cpp:6
Solution::dailyTemperatures
vector< int > dailyTemperatures(vector< int > &temperatures)
Definition
main.cpp:8
main
int main()
Definition
main.cpp:26
main.cpp
Generated by
1.9.8