DEV Community

Saranya R
Saranya R

Posted on

Search in Rotated Sorted Array

Approach Explanation ( •̀ ω •́ )✧

  1. I used binary search because the array is sorted but rotated.
  2. At each step, I checked which half (left or right) was sorted.
  3. If the target lay inside the sorted half, I searched there.
  4. Otherwise, I searched in the other half.
  5. This continued until I either found the target or exhausted the search space.

Method Used: ( ̄︶ ̄)↗ 

  • Binary search adaptation
  • Range checks
  • Efficient narrowing

Top comments (0)