Skip to content

Commit d438d07

Browse files
authored
Update BucketSort.java
防止越界,小于2的也不需要排序
1 parent b4ef1c8 commit d438d07

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

java/13_sorts/BucketSort.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class BucketSort {
1414
* @param bucketSize 桶容量
1515
*/
1616
public static void bucketSort(int[] arr, int bucketSize) {
17-
if (arr.length == 0) {
17+
if (arr.length < 2) {
1818
return;
1919
}
2020

0 commit comments

Comments
 (0)