Skip to content

Commit cd95291

Browse files
committed
修正 PHP 代码部分错误
1 parent a33fef7 commit cd95291

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

8.countingSort.md

Lines changed: 5 additions & 1 deletion
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)