You are viewing a single comment's thread. Return to all comments →
.
int results[] = new int[alice.length]; int rank = 1; int rankScore = scores[0]; for (int a = alice.length - 1, s = 0; a >= 0; a--) { if (alice[a] < rankScore) { for (; s < scores.length; s++) { if (scores[s] < rankScore) { rank++; rankScore = scores[s]; } if(alice[a] >= scores[s]) break; } } results[a] = s == scores.length ? rank + 1 : 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 →
Java O(n + m) Solution:
.