```
public int findPeakElement(int[] nums) {
if(nums.length==0) {
return Integer.MIN_VALUE;
}
Stack<Integer> stack = new Stack<>();
int pi = 0;
stack.push(0);
for(int i=1;i<nums.length;i++) {
int currIdx = stack.peek();
if(nums[i]>=nums[currIdx]) {
stack.pop();
pi = i;
stack.push(i);
continue;
}
break;
}
return stack.peek();
}
```