Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int peakIndexInMountainArray(const vector<int>& A) {
- int left = 0;
- int right = A.size() - 1;
- while (right - left > 1) {
- int mid = (left + right) / 2;
- if (A[mid] < A[mid + 1]) {
- left = mid;
- } else {
- right = mid;
- }
- }
- return right;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement