Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int peakIndexInMountainArray(const vector<int>& A) {
  4.         int left = 0;
  5.         int right = A.size() - 1;
  6.        
  7.         while (right - left > 1) {
  8.             int mid = (left + right) / 2;
  9.            
  10.             if (A[mid] < A[mid + 1]) {
  11.                 left = mid;
  12.             } else {
  13.                 right = mid;
  14.             }
  15.         }
  16.         return right;
  17.     }
  18. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement