Skip to content

Instantly share code, notes, and snippets.

@EronAlves1996
Created May 21, 2024 22:15
Show Gist options
  • Save EronAlves1996/366b590e92f4f9c9c041500fa5ef0529 to your computer and use it in GitHub Desktop.
Save EronAlves1996/366b590e92f4f9c9c041500fa5ef0529 to your computer and use it in GitHub Desktop.
void swapFives(int[] list) {
int start = 0;
int end = list.length - 1;
while (start < end) {
if (list[end] == 5) {
end--;
continue;
}
if (list[start] == 5) {
list[start] = list[end];
list[end] = 5;
end--;
}
start++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment