@@ -0,0 +1,1816 @@
+import java.io.*;%0Aimport java.util.*;%0Aimport java.text.*;%0Aimport java.math.*;%0Aimport java.util.regex.*;%0A%0A/**%0A*   Solution for https://www.hackerrank.com/challenges/the-grid-search/%0A*/%0Apublic class Solution %7B%0A  %0A    public static void main(String%5B%5D args) %7B%0A        Scanner in = new Scanner(System.in);%0A        int t = in.nextInt();%0A        for(int a0 = 0; a0 %3C t; a0++)%7B%0A            int R = in.nextInt();%0A            int C = in.nextInt();%0A            String G%5B%5D = new String%5BR%5D;%0A            for(int G_i=0; G_i %3C R; G_i++)%7B%0A                G%5BG_i%5D = in.next();%0A            %7D%0A            int r = in.nextInt();%0A            int c = in.nextInt();%0A            String P%5B%5D = new String%5Br%5D;%0A            for(int P_i=0; P_i %3C r; P_i++)%7B%0A                P%5BP_i%5D = in.next();%0A            %7D%0A%0A            if (isPresent(G, P)) %7B%0A                System.out.println(%22YES%22);%0A            %7D%0A            else %7B%0A                System.out.println(%22NO%22);%0A            %7D%0A        %7D%0A    %7D%0A%0A    private static boolean isPresent(String%5B%5D larger, String%5B%5D smaller) %7B%0A        int smallerIndex = 0;%0A%0A        for (int i = 0; i %3C larger.length; i++) %7B%0A            int index = larger%5Bi%5D.indexOf(smaller%5BsmallerIndex%5D);%0A%0A            if (index != -1) %7B //found%0A                boolean found = true;%0A                smallerIndex++;%0A%0A                for (int j = i + 1; j %3C larger.length && smallerIndex %3C smaller.length; j++, smallerIndex++) %7B%0A                    String toFind = smaller%5BsmallerIndex%5D;%0A%0A                    found &= larger%5Bj%5D.substring(index, index + toFind.length()).equals(toFind);%0A                %7D%0A%0A                if (found) %7B%0A                    return true;%0A                %7D%0A                else %7B%0A                    smallerIndex = 0; //reset and start again%0A                %7D%0A            %7D%0A        %7D%0A%0A        return false;%0A    %7D%0A%7D%0A

Create the-grid-search.java