Fixed median calculation bug due to float sort.

This commit is contained in:
softsimon 2020-03-23 00:33:15 +07:00
parent f7b4d9017a
commit 9509c702db
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
2 changed files with 0 additions and 2 deletions

View File

@ -203,7 +203,6 @@ class Blocks {
if (!numbers.length) { return 0; }
let medianNr = 0;
const numsLen = numbers.length;
numbers.sort();
if (numsLen % 2 === 0) {
medianNr = (numbers[numsLen / 2 - 1] + numbers[numsLen / 2]) / 2;
} else {

View File

@ -89,7 +89,6 @@ class ProjectedBlocks {
private median(numbers: number[]) {
let medianNr = 0;
const numsLen = numbers.length;
numbers.sort();
if (numsLen % 2 === 0) {
medianNr = (numbers[numsLen / 2 - 1] + numbers[numsLen / 2]) / 2;
} else {