You are viewing a single comment's thread. Return to all comments →
O(N) solution in C.
*result_count = player_count; int *results = malloc(player_count * sizeof(int)); int rank = 1, j = player_count-1; for (int i = 0; i < ranked_count; i++) { for (; ranked[i] <= player[j]; j--) results[j] = rank; if (ranked[i] > ranked[i+1] || i + 1 == ranked_count) rank++; } for (;j >= 0; j--) results[j] = rank; return results;
Seems like cookies are disabled on this browser, please enable them to open this website
Climbing the Leaderboard
You are viewing a single comment's thread. Return to all comments →
O(N) solution in C.