We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 39611ac commit c3bdd6eCopy full SHA for c3bdd6e
python/0162-find-peak-element.py
@@ -0,0 +1,13 @@
1
+class Solution:
2
+ def findPeakElement(self, nums: List[int]) -> int:
3
+ l, r = 0, len(nums) - 1
4
+ while l <= r:
5
+ mid = (r + l) // 2
6
+ if mid < len(nums) - 1 and nums[mid] < nums[mid+1]:
7
+ l = mid + 1
8
+ elif mid > 0 and nums[mid] < nums[mid-1]:
9
+ r = mid - 1
10
+ else:
11
+ break
12
+ return mid
13
+
0 commit comments