Counting Sort 1

  • + 0 comments

    My TypeScript solution:

    function countingSort(arr: number[]): number[] {
        const frequencyArray = (new Array(100)).fill(0);
        const length = arr.length;
        
        for (let i = 0; i < length; i++) {
            frequencyArray[arr[i]] += 1;
        }
    
        return frequencyArray;
    }