Peak Index in Mountain Array with Binary Search

🚀 Coding Challenge: Day 12 Solved Peak Index in a Mountain Array. ⚡ Approach: Used Binary Search instead of linear scan. Compared arr[mid] with arr[mid + 1]: If increasing → move right If decreasing → peak is on left (or mid) This helps directly reach the peak efficiently. ⚡ Time Complexity: ✔ O(log n) ⚡ Space Complexity: ✔ O(1) ⚡ Key Learning: ✔ Binary Search works on patterns, not just sorted arrays ✔ Identify increasing/decreasing trends #DSA #LeetCode #BinarySearch #CPlusPlus #ProblemSolving

  • graphical user interface, text

To view or add a comment, sign in

Explore content categories