IT评测·应用市场-qidao123.com

标题: leetcode 3285 找到稳固山的下标 [打印本页]

作者: 涛声依旧在    时间: 2024-12-21 17:50
标题: leetcode 3285 找到稳固山的下标
3285. 找到稳固山的下标
已解答
简朴
相干标签
相干企业
有 n 座山排成一列,每座山都有一个高度。给你一个整数数组 height ,此中 height 表现第 i 座山的高度,再给你一个整数 threshold 。
对于下标不为 0 的一座山,假如它左侧相邻的山的高度 严格大于 threshold ,那么我们称它是 稳固 的。我们定义下标为 0 的山 不是 稳固的。
请你返回一个数组,包含所有 稳固 山的下标,你可以以 恣意 次序返回下标数组。

示例 1:
输入:height = [1,2,3,4,5], threshold = 2
输出:[3,4]
解释:

示例 2:
输入:height = [10,1,10,1,10], threshold = 3
输出:[1,3]
示例 3:
输入:height = [10,1,10,1,10], threshold = 10
输出:[]

提示:

  1. class Solution:
  2.     def stableMountains(self, height: List[int], threshold: int) -> List[int]:
  3.         result = []
  4.         for i in range(1, len(height)):
  5.             if height[i-1] > threshold:
  6.                 result.append(i)
  7.         return result
复制代码


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 IT评测·应用市场-qidao123.com (https://dis.qidao123.com/) Powered by Discuz! X3.4