Counting Sort 1

  • + 0 comments

    My answer with Typescript, stuck a while cause dk 100 fixed size of result

    function countingSort(arr: number[]): number[] {
        let size = 100 // arr.length
        let frequency = new Array<number>(size).fill(0)
    
        for (let num of arr) frequency[num] = (frequency[num] || 0) + 1
    
        return frequency
    }