public class Solution { public int findPeakElement(int[] nums) { int length=nums.length; if(length==1) return 0; int i=0; for(;i<length-1;i++) { boolean flag=true; if(i!=0) { if(nums[i]<=nums[i-1]) flag=false; } if(flag==true&&nums[i]>nums[i+1]) { break; } } if(nums[length-1]>nums[length-2]) return length-1; return i; } }