Mediumbinary-search

Search in Rotated Sorted Array

TIME: O(log n)
SPACE: O(1)

Problem Statement

Given a sorted integer array nums that has been possibly rotated at an unknown pivot index, and a target value, return the index of target if it is in nums, or -1 if it is not. You must write an algorithm with O(log N) runtime complexity.

Real Engineering Applications

In production systems, this concept directly maps to caching index layers, route lookups optimizations, compiler scope parsing validations, and multi-thread dependency schedulers.

DevJam Practice Engine v1.0ACCESSIBLE LAB
solution.js
Console Output