Counting Sort 1

  • + 0 comments

    My solution in C:

    int* countingSort(int arr_count, int* arr, int* result_count) {
        static int table[100] = {0};    
        // A static variable in C is a special type of variable that has its value stored in memory for the entire lifespan of a program.
        *result_count = 100;
        for (int i = 0; i<arr_count; i++){
            table[arr[i]] ++;
        }
        return table;
    }