The template itself. Given a sorted array, maintain left and right,
pick mid, and discard half the space each step. When nums[mid] == target
you return the index; when the range collapses empty, the target isn't there.
Execution
idle
Press Run to begin.
0 / 0
Speed
Java · running line
leftmidrightfound
O(log n) time · O(1) space · mid = left + (right − left) / 2 avoids overflow; loop while left ≤ right.