Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8295e7f

Browse files
authored
Update BinarySearch.md
1 parent ab581ca commit 8295e7f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

‎binary-search/BinarySearch.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -804,11 +804,11 @@ class RotationCountOfRotatedArray {
804804
int mid = start + (end - start) / 2;
805805
if (mid < end
806806
&& arr[mid] > arr[mid
807-
+ 1]) // if mid is greater than the next element[^1^][1]
807+
+ 1]) // if mid is greater than the next element
808808
return mid + 1;
809809
if (mid > start
810810
&& arr[mid - 1] > arr[mid]) // if mid is smaller than the
811-
// previous element[^1^][1]
811+
// previous element
812812
return mid;
813813

814814
if (arr[start] < arr[mid]) { // left side is sorted, so the pivot is
@@ -852,11 +852,11 @@ class RotationCountWithDuplicates {
852852
int mid = start + (end - start) / 2;
853853
if (mid < end
854854
&& arr[mid] > arr[mid + 1]) // if element at mid is greater than
855-
// the next element[^1^][1]
855+
// the next element
856856
return mid + 1;
857857
if (mid > start
858858
&& arr[mid - 1] > arr[mid]) // if element at mid is smaller than
859-
// the previous element[^1^][1]
859+
// the previous element
860860
return mid;
861861

862862
// this is the only difference from the previous solution
@@ -865,11 +865,11 @@ class RotationCountWithDuplicates {
865865
// ends if they are not the smallest number
866866
if (arr[start] == arr[mid] && arr[end] == arr[mid]) {
867867
if (arr[start] > arr[start + 1]) // if element at start+1 is not
868-
// the smallest[^1^][1]
868+
// the smallest
869869
return start + 1;
870870
++start;
871871
if (arr[end - 1] > arr[end]) // if the element at end is not the
872-
// smallest[^1^][1]
872+
// smallest
873873
return end;
874874
--end;
875875
// left side is sorted, so the pivot is on right side
@@ -1324,4 +1324,4 @@ class Solution {
13241324
**Complexity:**
13251325
- Time: O(n log m), O(n log m), where n is the number of weights and m is the total weight. This is because we perform a binary search over the ship capacities, and for each capacity, we check if it’s possible to ship all weights within the given days in O(n) time.
13261326
- Space: O(1)
1327-
<hr>
1327+
<hr>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /