You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/leetcode/sort.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -215,7 +215,7 @@ public static void main(String[] args) {
215
215
216
216
我们随意抽取一个数作为基准值,同时设定一个标记 mark 代表左边序列最右侧的下标位置,当然初始为 0 ,接下来遍历数组,如果元素大于基准值,无操作,继续遍历,如果元素小于基准值,则把 mark + 1 ,再将 mark 所在位置的元素和遍历到的元素交换位置,mark 这个位置存储的是比基准值小的数据,当遍历结束后,将基准值与 mark 所在元素交换位置即可。
217
217
218
-
```
218
+
```java
219
219
publicstaticvoid sort(int[] arr) {
220
220
sort(arr, 0, arr.length -1);
221
221
}
@@ -256,7 +256,7 @@ private static int partition(int[] arr, int startIndex, int endIndex) {
256
256
257
257
我们来看一下实现代码,不同之处只有 partition 方法:
258
258
259
-
```
259
+
```java
260
260
publicstaticvoid sort(int[] arr) {
261
261
sort(arr, 0, arr.length -1);
262
262
}
@@ -369,6 +369,8 @@ private static int partition(int[] arr, int startIndex, int endIndex) {
0 commit comments