Skip to content

Instantly share code, notes, and snippets.

@dominicknguyen
Created April 14, 2016 22:22
Show Gist options
  • Select an option

  • Save dominicknguyen/738aeb3ebadf2e58b89b26ab77963f1c to your computer and use it in GitHub Desktop.

Select an option

Save dominicknguyen/738aeb3ebadf2e58b89b26ab77963f1c to your computer and use it in GitHub Desktop.
!!
int[] sort(int[] a, int num) {
for(int z = a.length -1; z > 1; z--) {
if(a[z] == num) {
int temp = a[0];
a[0] = num;
a[z] = temp;
}
if(a[z] < a[z - 1]) {
int temp = a[z];
a[z] = a[z-1];
a[z- 1] = temp;
}
}
return a;
}
@dominicknguyen

Copy link
Copy Markdown
Author

Moves target number to 0. Sorts remaining elements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment