@@ -21,6 +21,9 @@ public void test() {
2121 int [] arr2 = {6 ,4 ,1 ,8 ,9 ,2 ,7 ,5 ,3 };
2222 int [] sortedArr2 = {1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 };
2323 assertThat (solution (arr2 , 0 , arr2 .length - 1 ), is (sortedArr2 ));
24+ int [] arr4 = {6 ,4 ,2 ,10 ,9 ,1 ,7 ,11 ,5 ,3 ,0 ,8 };
25+ int [] sortedArr4 = {0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 };
26+ assertThat (solution (arr4 , 0 , arr4 .length - 1 ), is (sortedArr4 ));
2427 int [] arr3 = {1 };
2528 int [] sortedArr3 = {1 };
2629 assertThat (solution (arr3 , 0 , arr3 .length - 1 ), is (sortedArr3 ));
@@ -45,12 +48,14 @@ private int partition(int[] arr, int left, int right) {
4548 int pivotValue = arr [right ];
4649 int endOfLowBlock = left - 1 ;
4750
48- for (int pos = left ; pos < right ; pos ++ ) {
51+ for (int pos = left ; pos < right ; ++ pos ) {
4952 if (pivotValue > arr [pos ]) {
50- Utils .swapValue (arr , pos , ++endOfLowBlock );
53+ endOfLowBlock += 1 ;
54+ Utils .swapValue (arr , pos , endOfLowBlock );
5155 }
5256 }
53- Utils .swapValue (arr , right , ++endOfLowBlock );
57+ endOfLowBlock += 1 ;
58+ Utils .swapValue (arr , right , endOfLowBlock );
5459
5560 return endOfLowBlock ;
5661 }
0 commit comments