From 732802f9cb464c3b7413d4d6ebb3d2d0ceaeaee7 Mon Sep 17 00:00:00 2001 From: Rain120 <1085131904@qq.com> Date: Mon, 31 Jan 2022 18:00:08 +0800 Subject: [PATCH 1/2] Update 8.countingSort.md --- 8.countingSort.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/8.countingSort.md b/8.countingSort.md index d0930cf..5bd462a 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 +``` From 2d18530328bfbf4d3fe39e2bd3287a913e82bfd9 Mon Sep 17 00:00:00 2001 From: Rain120 <1085131904@qq.com> Date: Mon, 31 Jan 2022 18:05:14 +0800 Subject: [PATCH 2/2] Update 8.countingSort.md --- 8.countingSort.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/8.countingSort.md b/8.countingSort.md index 5bd462a..75ffd0a 100644 --- a/8.countingSort.md +++ b/8.countingSort.md @@ -11,7 +11,7 @@ ```js function countingSort(arr) { - var maxValue = Math.max([...arr]); + var maxValue = Math.max(...arr); var bucket = new Array(maxValue+1), sortedIndex = 0; arrLen = arr.length,