Advertisement
nikunjsoni

162

May 14th, 2021
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int findPeakElement(vector<int>& nums) {
  4.         int l=0, r=nums.size()-1;
  5.         while(l<r){
  6.             int mid = (l+r)/2;
  7.             if(nums[mid] > nums[mid+1])
  8.                 r = mid;
  9.             else
  10.                 l = mid+1;
  11.         }
  12.         return l;
  13.     }
  14. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement