We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8f8f66f commit 567c19dCopy full SHA for 567c19d
solution/0162.Find Peak Element/Solution.java
@@ -0,0 +1,11 @@
1
+class Solution {
2
+ public int findPeakElement(int[] nums) {
3
+ int left = 0, right = nums.length - 1;
4
+ while (left < right) {
5
+ int mid = (left + right) / 2;
6
+ if(nums[mid] < nums[mid + 1]) left = mid + 1;
7
+ else right = mid;
8
+ }
9
+ return left;
10
11
+}
0 commit comments