public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] arr = new int[n];
for (int i = 0; i < arr.length; i++) {
arr[i] = sc.nextInt();
}
Insertionsort(arr);
Display(arr);
}
public static void Insertionsort(int arr[]) {
for (int counter = 1; counter <= arr.length - 1; counter++) {
int val = arr[counter];
int j = counter - 1;
while (j >= 0 && arr[j] > val) {
arr[j + 1] = arr[j];
j--;
}
arr[j + 1] = val;
}
}
public static void Display(int[] arr) {
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
}
code is right but all the test cases are failing