1class Solution {2public int peakIndexInMountainArray(int[] arr) {34int start = 0;5int end = arr.length - 1;67while (start < end) {8int mid = start + (end - start) / 2;9// if mid < mid next10if (arr[mid] < arr[mid + 1]) {11start = mid + 1;12}13// otherwise it can either peak element or greater element14else {15end = mid;16}17}18return start; // or we can return end also, bcz both will be on same value at the time, that's19// why loop breaks here.20}21}