Binary Search
1 | class Solution { |
Remarks:
- TC: $O(\log n)$
- In a standard binary search senario,
leftis always the first index that is>=target;rightis at the last index that is<target. Why? because thewhilecondition isleft <= right, and the loop ends whenleft > right.