Search in Rotated Sorted Array with Binary Search

75 days of solving DSA problems. One thing I've learned so far: Many problems are just variations of classic algorithms. Today was a perfect example. 🚀 Day 75/365 — DSA Challenge Solved: Search in Rotated Sorted Array The Problem Normally, Binary Search works on a sorted array. But what if the array was rotated? 💡 My Approach This problem is solved using a modified Binary Search. At each step: 1️⃣ Find the middle element 2️⃣ Check which side is sorted Left sorted: nums[left] <= nums[mid] Right sorted: nums[mid] <= nums[right] 3️⃣ Decide which half to search based on where the target can exist This keeps the search time at O(log n). Complexity ⏱ Time: O(log n) 📦 Space: O(1) Day 75/365 complete. 💻 290 days to go. Code 👇 https://lnkd.in/dad5sZfu #DSA #Java #LeetCode #BinarySearch #Algorithms #LearningInPublic

  • text

To view or add a comment, sign in

Explore content categories