Skip to content

Instantly share code, notes, and snippets.

@VallarasuS
Created March 16, 2023 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VallarasuS/6a7c9efed9a6ef53c71e196fbfe416fb to your computer and use it in GitHub Desktop.
Save VallarasuS/6a7c9efed9a6ef53c71e196fbfe416fb to your computer and use it in GitHub Desktop.
Insertion Sort
class Solution {
public void insertionSort(int[] numbsers) {
for(int i = 1; i < numbsers.length; i++) {
int item = numbsers[i];
int j = i - 1;
while (j >= 0 && item < numbsers[j]) {
numbsers[j + 1] = numbsers[j];
j--;
}
numbsers[j + 1] = item;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment