Find Peak Element LeetCode solution in Java
1class Solution {2public int findPeakElement(int[] nums) {3int start = 0;4int end = nums.length - 1;56while (start < end) {7int mid = start + (end - start) / 2;8if (nums[mid] > nums[mid + 1]) {9// It means that we are in decreasing part of the array10end = mid;11} else {12// It means that we are in increasing part of the array13start = mid + 1;14}15}16return start;17}18}