class Solution {public: int peakIndexInMountainArray(vector & A) { int res=0; for(int i=0;iA[res]){ res=i; } } return res; }};class Solution {public: int rec(vector & A, int left, int right){ int mid = (left + right) / 2; if(mid == 0 || mid == A.size()-2){ if(A[mid] > A[mid+1]){ return mid; } else{ return mid+1; } } else{ if(A[mid] > A[mid-1] && A[mid] > A[mid+1]){ return mid; } else if(A[mid] > A[mid-1]){ return rec(A, mid, right); } else if(A[mid] < A[mid-1]){ return rec(A, left, mid-1); } } } int peakIndexInMountainArray(vector & A) { return rec(A, 0, A.size()-1); }};