```
public int findPeakElement(int[] nums) {
return findIt(nums,0,nums.length-1);
}
public int findIt(int[] nums, int start, int end){
int mid = (start+end)/2;
if(mid==start) return nums[start]>nums[end]?start:end;
if(nums[mid-1]<nums[mid]&&nums[mid]>nums[mid+1]) return mid;
if(nums[mid-1]>nums[mid]) return findIt(nums,start,mid-1);
else return findIt(nums,mid+1,end);
}
```