Skip to content

Commit d0eeb0a

Browse files
33. Search in Rotated Sorted Array (java) (optimized code)
1 parent c21fd8a commit d0eeb0a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

solution/0033.Search in Rotated Sorted Array/Solution.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ public int search(int[] A, int target) {
33
if (A == null || A.length == 0) return -1;
44
int low = 0,high = A.length - 1;
55
while (low <= high) {
6-
int mid = (low + high) / 2;
6+
int mid = low + ((high - low) >> 1);
77
if (target < A[mid]) {
88
if (A[mid] >= A[high] && target < A[low]) low = mid + 1;
99
else high = mid - 1;

0 commit comments

Comments
 (0)