We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Counting Sort 1
- Discussions
Counting Sort 1
Counting Sort 1
Sort by
recency
|
236 Discussions
|
Please Login in order to post a comment
My Java approach:
JavaScript solution:
Java Solution
include
include
include
include
include
include
include
include
include
include
char* readline(); char* ltrim(char*); char* rtrim(char*); char** split_string(char*);
int parse_int(char*);
/* * Complete the 'countingSort' function below. * * The function is expected to return an INTEGER_ARRAY. * The function accepts INTEGER_ARRAY arr as parameter. */
/* * To return the integer array from the function, you should: * - Store the size of the array to be returned in the result_count variable * - Allocate the array statically or dynamically * * For example, * int* return_integer_array_using_static_allocation(int* result_count) { * *result_count = 5; * * static int a[5] = {1, 2, 3, 4, 5}; * * return a; * } * * int* return_integer_array_using_dynamic_allocation(int* result_count) { * *result_count = 5; * * int *a = malloc(5 * sizeof(int)); * * for (int i = 0; i < 5; i++) { * *(a + i) = i + 1; * } * * return a; * } * / int countingSort(int arr_count, int* arr, int* result_count) { // Allocate memory for the frequency array int* frequency_array = (int*)malloc(100 * sizeof(int)); if (frequency_array == NULL) { fprintf(stderr, "Memory allocation failed\n"); return NULL; // Return NULL if memory allocation fails }
}
int main() { FILE* fptr = fopen(getenv("OUTPUT_PATH"), "w");
}
char* readline() { size_t alloc_length = 1024; size_t data_length = 0;
}
char* ltrim(char* str) { if (!str) { return '\0'; }
}
char* rtrim(char* str) { if (!str) { return '\0'; }
}
char** split_string(char* str) { char** splits = NULL; char* token = strtok(str, " ");
}
int parse_int(char* str) { char* endptr; int value = strtol(str, &endptr, 10);
}
Java Solution
Java 8 Streams