Skip to content

Commit 64edfb4

Browse files
authored
Create find-indices-of-stable-mountains.cpp
1 parent fa313b5 commit 64edfb4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Time: O(n)
2+
// Space: O(1)
3+
4+
// array
5+
class Solution {
6+
public:
7+
vector<int> stableMountains(vector<int>& height, int threshold) {
8+
vector<int> result;
9+
for (int i = 1; i < size(height); ++i) {
10+
if (height[i - 1] > threshold) {
11+
result.emplace_back(i);
12+
}
13+
}
14+
return result;
15+
}
16+
};

0 commit comments

Comments
 (0)