难度:简单
有
n座山排成一列,每座山都有一个高度。给你一个整数数组height,其中height[i]表示第i座山的高度,再给你一个整数threshold。对于下标不为
0的一座山,如果它左侧相邻的山的高度 严格大于threshold,那么我们称它是 稳定 的。我们定义下标为0的山 不是 稳定的。请你返回一个数组,包含所有 稳定 山的下标,你可以以 任意 顺序返回下标数组。
示例 1:
输入:height = [1,2,3,4,5], threshold = 2
输出:[3,4]
解释:
- 下标为 3 的山是稳定的,因为
height[2] == 3大于threshold == 2。- 下标为 4 的山是稳定的,因为
height[3] == 4大于threshold == 2.示例 2:
输入:height = [10,1,10,1,10], threshold = 3
输出:[1,3]
示例 3:
输入:height = [10,1,10,1,10], threshold = 10
输出:[]
提示:
2 <= n == height.length <= 100
1 <= height[i] <= 100
1 <= threshold <= 100
题解:class Solution: def stableMountains(self, height: List[int], threshold: int) -> List[int]: res = [] for i in range(1,len(height)): if height[i-1] > threshold: res.append(i) return res















![vsCode 报错[vue/no-v-model-argument]e‘v-model‘ directives require no argument](https://i-blog.csdnimg.cn/direct/be74560078fb44a19ec7a5ca2aa48713.png)




