class Solution { public int findPeakElement(int[] nums) { if(nums.length==1||nums[0]>nums[1]){ return 0; } if(nums[nums.length-1]>nums[nums.length-2]){ return nums.length-1; } int left=0; int right = nums.length-1; int mid=0; while(left<=right){ mid = (left + right)>>1; if(nums[mid]>nums[mid+1]){ right = mid-1; } else{ left = mid +1; } } return left; } }