From cd952912c783c3a68ee379772106a15c667bffe6 Mon Sep 17 00:00:00 2001 From: TonyHe Date: Tue, 13 Aug 2019 17:54:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20PHP=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=83=A8=E5=88=86=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 8.countingSort.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/8.countingSort.md b/8.countingSort.md index efabf9c..d0930cf 100644 --- a/8.countingSort.md +++ b/8.countingSort.md @@ -149,7 +149,11 @@ function countingSort($arr, $maxValue = null) $sortedIndex = 0; foreach ($bucket as $key => $len) { - if ($len !== null) $arr[$sortedIndex++] = $key; + if($len !== null){ + for($j = 0; $j < $len; $j++){ + $arr[$sortedIndex++] = $key; + } + } } return $arr;