Skip to content

Commit e28c81a

Browse files
committed
Prevent overflow for large integer numbers
1 parent d33f111 commit e28c81a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

problems/src/binary_search/SearchRotatedSortedArray.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public int search(int[] nums, int target)
3434
int low = 0, high = nums.length - 1;
3535
while(low < high)
3636
{
37-
int mid = (low + high) / 2;
37+
int mid = (low + high) >>> 1;
3838
if(nums[mid] == target)
3939
return mid;
4040
if((nums[mid] <= nums[low]) && (target > nums[mid] && target <= nums[high]) ||

0 commit comments

Comments
 (0)