diff --git a/8.countingSort.md b/8.countingSort.md index d0930cf..75ffd0a 100644 --- a/8.countingSort.md +++ b/8.countingSort.md @@ -10,7 +10,8 @@ ## 2. JavaScript 代码实现 ```js -function countingSort(arr, maxValue) { +function countingSort(arr) { + var maxValue = Math.max(...arr); var bucket = new Array(maxValue+1), sortedIndex = 0; arrLen = arr.length, @@ -158,4 +159,4 @@ function countingSort($arr, $maxValue = null) return $arr; } -``` \ No newline at end of file +```