by Franziska Hinkelmann
My Favorite Linear-time Sorting Algorithm
Counting sort with a twist
The problem: Given an unsorted array of numbers, find the maximum difference between the successive elements in its sorted form. The numbers can be negative or decimals.
Straightforward Algorithm
const maxGap = input => input .sort((a, b) => a — b) .reduce((acc, cur, idx…