We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7a84ba8 commit 97d7a48Copy full SHA for 97d7a48
codes/javascript/chapter_sorting/radix_sort.js
@@ -41,12 +41,7 @@ function countingSortDigit(nums, exp) {
41
/* 基数排序 */
42
function radixSort(nums) {
43
// 获取数组的最大元素,用于判断最大位数
44
- let m = Number.MIN_VALUE;
45
- for (const num of nums) {
46
- if (num > m) {
47
- m = num;
48
- }
49
+ let m = Math.max(... nums);
50
// 按照从低位到高位的顺序遍历
51
for (let exp = 1; exp <= m; exp *= 10) {
52
// 对数组元素的第 k 位执行计数排序
0 commit comments