3285. Find Indices of Stable Mountains Easy
1/**
2 * [3285] Find Indices of Stable Mountains
3 *
4 * There are n mountains in a row, and each mountain has a height. You are given an integer array height where height[i] represents the height of mountain i, and an integer threshold.
5 * A mountain is called stable if the mountain just before it (if it exists) has a height strictly greater than threshold. Note that mountain 0 is not stable.
6 * Return an array containing the indices of all stable mountains in any order.
7 *
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">height = [1,2,3,4,5], threshold = 2</span>
11 * Output: <span class="example-io">[3,4]</span>
12 * Explanation:
13 *
14 * Mountain 3 is stable because height[2] == 3 is greater than threshold == 2.
15 * Mountain 4 is stable because height[3] == 4 is greater than threshold == 2.
16 * </div>
17 * <strong class="example">Example 2:
18 * <div class="example-block">
19 * Input: <span class="example-io">height = [10,1,10,1,10], threshold = 3</span>
20 * Output: <span class="example-io">[1,3]</span>
21 * </div>
22 * <strong class="example">Example 3:
23 * <div class="example-block">
24 * Input: <span class="example-io">height = [10,1,10,1,10], threshold = 10</span>
25 * Output: <span class="example-io">[]</span>
26 * </div>
27 *
28 * Constraints:
29 *
30 * 2 <= n == height.length <= 100
31 * 1 <= height[i] <= 100
32 * 1 <= threshold <= 100
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/find-indices-of-stable-mountains/
38// discuss: https://leetcode.com/problems/find-indices-of-stable-mountains/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn stable_mountains(height: Vec<i32>, threshold: i32) -> Vec<i32> {
44 vec![]
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_3285() {
56 }
57}
58
Back
© 2025 bowen.ge All Rights Reserved.