@@ -0,0 +1,1035 @@
+//https://www.hackerrank.com/challenges/grid-challenge%0Aimport java.io.*;%0Aimport java.util.Arrays;%0A%0Apublic class Solution %7B%0A  public static void main(String%5B%5D args) throws IOException %7B%0A    StringBuffer sb = new StringBuffer();%0A    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));%0A%0A    //For each test case%0A    for(byte T = Byte.parseByte(br.readLine()); T %3E 0; --T)%7B%0A%0A      //Get input%0A      final byte N = Byte.parseByte(br.readLine());%0A      final char%5B%5D%5B%5D G = new char%5BN%5D%5B%5D;%0A      for(int y = 0; y %3C N; G%5By++%5D = br.readLine().toCharArray());%0A      %0A      //Sort rows%0A      for(int y = 0; y %3C N; Arrays.sort(G%5By++%5D))%7B%7D%0A      %0A      //Check if columns are sorted%0A      boolean isSorted = true;%0A      for(int x = 0; x %3C N; ++x)%7B%0A        for(int y = 1; y %3C N; ++y)%7B%0A          if(G%5By%5D%5Bx%5D %3C G%5By-1%5D%5Bx%5D)%7B%0A            x = N;%0A            isSorted = false;%0A            break;%0A          %7D%0A        %7D%0A      %7D%0A      %0A      //Print output%0A      sb.append(isSorted ? %22YES%5Cn%22 : %22NO%5Cn%22);%0A    %7D%0A    System.out.print(sb);%0A  %7D%0A%7D%0A

Create grid-challenge.java