Skip to content

Instantly share code, notes, and snippets.

@RakhmedovRS
Created October 20, 2022 02:33
Show Gist options
  • Select an option

  • Save RakhmedovRS/a64ac9609e188cc9f7788d89cf25ff34 to your computer and use it in GitHub Desktop.

Select an option

Save RakhmedovRS/a64ac9609e188cc9f7788d89cf25ff34 to your computer and use it in GitHub Desktop.
int pos = max;
int[] answer = new int[k];
int i = 0;
while (pos >= 0) {
for (int value : buckets.get(pos)) {
answer[i++] = value;
if (i == k) {
return answer;
}
}
pos--;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment