mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-06 17:50:39 +08:00
Updated the count sort algorithm with stable implementation. Added ES6 syntactic sugar to the syntax
This commit is contained in:
@ -28,9 +28,7 @@ const countingSort = (arr, min, max) => {
|
|||||||
res[count[arr[i] - min]] = arr[i]
|
res[count[arr[i] - min]] = arr[i]
|
||||||
count[arr[i] - min]--
|
count[arr[i] - min]--
|
||||||
}
|
}
|
||||||
// Copy the result back to back to original array
|
return res
|
||||||
arr = [...res]
|
|
||||||
return arr
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user