File tree 2 files changed +15
-1
lines changed
algorithms/medium/findPeakElement
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ LeetCode Problems' Solutions in JavaScript
17
17
## medium
18
18
19
19
1 . [ 数组中的第 K 个最大元素] ( ./algorithms/medium/findKthLargest/findKthLargest.js )
20
- 1 . [ 分类颜色] ( ./algorithms/medium/sortColors/sortColors.js )
20
+ 2 . [ 分类颜色] ( ./algorithms/medium/sortColors/sortColors.js )
21
+ 3 . [ 寻找峰值] ( ./algorithms/medium/findPeakElement/findPeakElement.js )
21
22
22
23
## hard
Original file line number Diff line number Diff line change
1
+ // description: https://leetcode-cn.com/explore/interview/card/top-interview-questions-medium/50/sorting-and-searching/99/
2
+ // 寻找峰值
3
+
4
+ /**
5
+ * @param {number[] } nums
6
+ * @return {number }
7
+ */
8
+ var findPeakElement = function ( nums ) {
9
+ for ( var i = 0 , len = nums . length ; i < len - 1 ; i ++ ) {
10
+ if ( nums [ i ] > nums [ i + 1 ] ) return i ;
11
+ }
12
+ return nums . length - 1 ;
13
+ } ;
You can’t perform that action at this time.
0 commit comments