Last active
May 22, 2024 12:43
-
-
Save marcelmcz/236c6a2131a2ee6d7e8e26ca5ca74eb8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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