Bitonic Point
Prashant Mishra

Prashant Mishra @prashantrmishra

About: There is always a price for those who persevere.

Location:
India
Joined:
Jul 2, 2022

Bitonic Point

Publish Date: Jul 1
0 0

Problem
TC: O(logn)

// User function Template for Java

class Solution {
    public int findMaximum(int[] arr) {
        // code here
        //plain binary search
        int low  =0;
        int high = arr.length-1;
        while(low<high){
            int mid = (low + high)/2;

            if(arr[mid] < arr[mid+1]){
                low = low+1;
            }
            else high = mid;
        }
        return arr[high];
    }
}
Enter fullscreen mode Exit fullscreen mode

Comments 0 total

    Add comment