2. Bitonic Point
The problem can be found at the following link: 🔗 Question Link
🧩 Problem Description
Given an array arr[] of n elements that is first strictly increasing and then (optionally) strictly decreasing, return the Bitonic Point — the maximum element in the array. It is guaranteed that the array contains exactly one bitonic point.
A Bitonic Point is the element where the sequence changes from increasing to decreasing — or simply the largest number in a bitonic array.
Edge Cases:
Entirely increasing → last element is peak.
Entirely decreasing → first element is peak.
📘 Examples
Example 1:
Input:
arr = [1, 2, 4, 5, 7, 8, 3]Output:
8Explanation:
Increasing:
[1, 2, 4, 5, 7]Peak:
8Decreasing:
[3]
Example 2:
Input:
Output:
Explanation:
Increasing:
[10, 20, 30, 40]Peak:
50Decreasing:
[]
Example 3:
Input:
Output:
Explanation:
Increasing:
[]Peak:
120Decreasing:
[100, 80, 20, 0]
🔒 Constraints
$3 \leq n \leq 10^5$
$1 \leq arr[i] \leq 10^6$
✅ My Approach
Optimized Approach: Binary Search on Bitonic Pattern
We observe that:
If
arr[mid] > arr[mid+1], then the maximum lies to the left (including mid).If
arr[mid] < arr[mid+1], then the maximum lies to the right.
This is a classical bitonic binary search:
We use a variant of binary search to reduce the search space logarithmically.
We stop when we find the peak element such that
arr[mid] > arr[mid-1] && arr[mid] > arr[mid+1].
Algorithm Steps:
Initialize
low = 0,high = n - 1.While
low < high:Compute
mid = (low + high) // 2.If
arr[mid] < arr[mid + 1]: Move right →low = mid + 1Else: Move left (may include mid) →
high = mid
Return
arr[low]as the maximum bitonic point.
🧮 Time and Auxiliary Space Complexity
Expected Time Complexity: O(log n), as we use binary search to find the peak.
Expected Auxiliary Space Complexity: O(1), as we only use a constant amount of additional variables.
🧠 Code (C++)
🧑💻 Code (Java)
🐍 Code (Python)
🧠 Contribution and Support
For discussions, questions, or doubts related to this solution, feel free to connect on LinkedIn: 📬 Any Questions?. Let’s make this learning journey more collaborative!
⭐ If you find this helpful, please give this repository a star! ⭐
📍Visitor Count
Last updated