package hackerrank;

import java.util.Scanner;

/**
 * https://www.hackerrank.com/challenges/insertionsort2
 */
public class InsertionSortPart2 {
    public static void insertionSortPart2(int[] ar) {
        
    }


    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int s = in.nextInt();
        int[] ar = new int[s];
        for (int i = 0; i < s; i++) {
            ar[i] = in.nextInt();
        }
        insertionSortPart2(ar);

    }

    private static void printArray(int[] ar) {
        for (int n : ar) {
            System.out.print(n + " ");
        }
        System.out.println("");
    }
}

@@ -201,23 +201,372 @@
         
+for (int i = 1; i %3C ar.length; i++) %7B%0A            int j = i;%0A            while (j %3E= 1 && ar%5Bj%5D %3C ar%5Bj - 1%5D) %7B%0A                swap(ar, j, j - 1);%0A                j--;%0A            %7D%0A            printArray(ar);%0A        %7D%0A    %7D%0A%0A    private static void swap(int%5B%5D ar, int i, int j) %7B%0A        int tmp = ar%5Bi%5D;%0A        ar%5Bi%5D = ar%5Bj%5D;%0A        ar%5Bj%5D = tmp;
 %0A    %7D
-%0A
 %0A%0A    pu

Solve Insertion Sort: Part 2