Commit 962165d
committed
fix: handle zero and negative numbers in RadixSort getLengthOfLongestElement
Math.log10(0) returns -Infinity and Math.log10(-N) returns NaN, causing the sorting loop to never execute for arrays containing only zeros or negative numbers.
Added early return for edge cases where max value is 0 or negative.1 parent 3b53377 commit 962165d
1 file changed
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
117 | 120 | | |
118 | 121 | | |
119 | 122 | | |
| |||
0 commit comments