BinarySearch
- Why do we do low <= high? instead of low < high?
- The search will continue as long as there is at least one element in the range (
low == high
). - When
low > high
, the range becomes invalid (no elements left to check).
- The search will continue as long as there is at least one element in the range (
-
This condition ensures we don't miss any element, including the middle element in the last range when
low == high
. - findUpperBound
- targetElementInRotatedSortedArray
- targetElementInRotatedSortedArray2
- 153. Find Minimum in Rotated Sorted Array
- FindNumberOfRotations
- AggressiveCows
- bookAllocation