标签:
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; } }
标签:
原文地址:http://www.cnblogs.com/aguai1992/p/5347570.html