Skip to content

Commit 682abe5

Browse files
authored
Binary Search
1 parent 31e3fbe commit 682abe5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

55. 162. Find Peak Element

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public int findPeakElement(int[] nums) {
3+
int start=0;
4+
int end=nums.length-1;
5+
while(start<end){
6+
int mid=start+(end-start)/2;
7+
if(nums[mid]<=nums[mid+1]){
8+
start=mid+1;
9+
}else{
10+
end=mid;
11+
}
12+
}
13+
return start;
14+
}
15+
}

0 commit comments

Comments
 (0)