// The query API is defined in the parent class Getvalue:
// int query(int x);
// return int means nums[x].
class Solution extends Getvalue {
public int findPeakElement(int n) {
int left = 0, right = n - 1;
while(left <= right){
int mid = left + (right - left) / 2;
int lVaule = query(mid), rValue = 0;
if(mid + 1 == n){
rValue = Integer.MIN_VALUE;
}else{
rValue = query(mid + 1);
}
if(lVaule < rValue){
left = mid + 1;
}else{
right = mid - 1;
}
}
return left;
}
}