Skip to content

Commit a2443c8

Browse files
ttttonyhehustcc
authored andcommitted
修正 PHP 代码部分错误 (#35)
1 parent 6cd1226 commit a2443c8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

8.countingSort.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ function countingSort($arr, $maxValue = null)
149149

150150
$sortedIndex = 0;
151151
foreach ($bucket as $key => $len) {
152-
if ($len !== null) $arr[$sortedIndex++] = $key;
152+
if($len !== null){
153+
for($j = 0; $j < $len; $j++){
154+
$arr[$sortedIndex++] = $key;
155+
}
156+
}
153157
}
154158

155159
return $arr;

0 commit comments

Comments
 (0)