/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class PositiveNegativeSeperateUsingDNF { public static void main (String[] args) throws java.lang.Exception { // your code goes here int A[] = {2,4,-5,0,-7,-2,2,-5,1,-9,-7,-1}; DutchNationalFlag(A); for(int i:A) System.out.print(i+" "); } public static void DutchNationalFlag(int[] A) { int posStartIndex = 0; for (int i = 0; i < A.length; i++) { if (A[i] < 0) { int temp = A[i]; for (int j = i; j > posStartIndex; j--) { A[j] = A[j-1]; } A[posStartIndex] = temp; if (A[i] < 0) posStartIndex++; } } } }