We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 08f6489 commit a44b806Copy full SHA for a44b806
162. Find Peak Element
@@ -0,0 +1,17 @@
1
+//.........................Binary Search.......................................//
2
+//same as Leetcode 852. find peak Element
3
+ int findPeakElement(vector<int>& nums) {
4
+ // This question is same as leetCode 852.peak index in a mountain array
5
+ int left =0;
6
+ int right = nums.size() - 1;
7
+ while(left < right){
8
+ int mid = left+(right-left)/2;
9
+ if(nums[mid] < nums[mid+1]){
10
+ left = mid+1;
11
+ }
12
+ else{
13
+ right = mid;
14
15
16
+ return left;
17
0 commit comments