Skip to content

Instantly share code, notes, and snippets.

@marcelmcz
Last active May 22, 2024 12:43
Show Gist options
  • Save marcelmcz/236c6a2131a2ee6d7e8e26ca5ca74eb8 to your computer and use it in GitHub Desktop.
Save marcelmcz/236c6a2131a2ee6d7e8e26ca5ca74eb8 to your computer and use it in GitHub Desktop.
private static void fiveToTheEnd(int[] array) {
pointer1:
for(int i=array.length-1; i>0; i--){
if(array[i] != 5) {
for(int o=i-1; o>=0; o--){
if(array[o] == 5){
int temp = array[i];
array[i] = array[o];
array[o] = temp;
break;
}
if(o == 0){
break pointer1;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment