Advertisement
Guest User

Untitled

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