aboutsummaryrefslogtreecommitdiff
path: root/other/daily_temps.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'other/daily_temps.cpp')
-rw-r--r--other/daily_temps.cpp28
1 files changed, 0 insertions, 28 deletions
diff --git a/other/daily_temps.cpp b/other/daily_temps.cpp
deleted file mode 100644
index e244252..0000000
--- a/other/daily_temps.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-#include "leetcode.h"
-
-class Solution {
-public:
- vector<int> dailyTemperatures(vector<int> &temperatures) {
- int n = temperatures.size();
- vector<int> nge(n, 0);
- stack<int> stk{};
- for (int i = n - 1; i >= 0; --i) {
- while (!stk.empty() && temperatures[stk.top()] <= temperatures[i])
- stk.pop();
- if (!stk.empty())
- nge[i] = stk.top() - i;
- stk.push(i);
- }
- return nge;
- }
-};
-
-int main() {
- Solution obj;
- vector<int> t1 = {73, 74, 75, 71, 69, 72, 76, 73};
- vector<int> t2 = {30, 40, 50, 60};
- vector<int> t3 = {30, 60, 90};
- obj.dailyTemperatures(t1); // expect 1,1,4,2,1,1,0,0
- obj.dailyTemperatures(t2); // expect 1,1,1,0
- obj.dailyTemperatures(t3); // expect 1,1,0
-}