Skip to content

Commit 77eae94

Browse files
authored
Update QuickSort.cpp
1 parent 8c5bd31 commit 77eae94

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Sort Algorithms/QuickSort.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ void quickSort(vector<int>& nums, int low, int high) {
88
while (l < h && nums[h] >= pivot)
99
--h;
1010
nums[l] = nums[h];
11-
while (low < high && nums[low] <= pivot)
12-
++low;
13-
nums[high] = nums[low];
11+
while (l < h && nums[l] <= pivot)
12+
++l;
13+
nums[h] = nums[l];
1414
}
1515

16-
nums[low] = pivot;
16+
nums[l] = pivot;
1717

18-
quickSort(nums, low + 1, h);
19-
quickSort(nums, l, low - 1);
18+
quickSort(nums, low, l-1);
19+
quickSort(nums, l+1, high);
2020
}
2121
}

0 commit comments

Comments
 (0)