@@ -0,0 +1,1638 @@
+//https://www.hackerrank.com/challenges/the-grid-search%0Aimport java.io.*;%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%0A    for(byte T = Byte.parseByte(br.readLine()); T %3E 0; --T)%7B%0A      %0A      //Get grid%0A      String%5B%5D s = br.readLine().split(%22 %22);%0A      short Y = Short.parseShort(s%5B0%5D);%0A      short X = Short.parseShort(s%5B1%5D);%0A      final char%5B%5D%5B%5D grid = new char%5BY%5D%5B%5D;%0A      for(short y = 0; y %3C Y; grid%5By++%5D = br.readLine().toCharArray())%7B%7D%0A      %0A      //Get pattern%0A      s = br.readLine().split(%22 %22);%0A      final short pY = Short.parseShort(s%5B0%5D);%0A      final short pX = Short.parseShort(s%5B1%5D);%0A      final char%5B%5D%5B%5D pattern = new char%5BpY%5D%5B%5D;%0A      for(short y = 0; y %3C pY; pattern%5By++%5D = br.readLine().toCharArray())%7B%7D%0A      %0A      //Check if pattern in grid%0A      sb.append((hasPattern(grid, Y, X, pattern, pY, pX)) ? %22YES%5Cn%22 : %22NO%5Cn%22);%0A    %7D%0A    %0A    //Print output%0A    System.out.print(sb);%0A  %7D%0A%0A  //Check if pattern in grid%0A  private static boolean hasPattern(char%5B%5D%5B%5D grid, short Y, short X, char%5B%5D%5B%5D pattern, short pY, short pX)%7B%0A    Y -= pY - 1;%0A    X -= pX - 1;%0A    for(short y = 0; y %3C Y; ++y)%7B%0A      for(short x = 0; x %3C X; ++x)%7B%0A        for(short py = 0; py %3C pY;)%7B%0A          short px;%0A          for(px = 0; px %3C pX && grid%5By + py%5D%5Bx + px%5D == pattern%5Bpy%5D%5Bpx%5D; ++px)%7B%7D%0A          if(px %3C pX)%7B%0A            break;%0A          %7D%0A          if(++py == pY)%7B%0A            return true;%0A          %7D%0A        %7D%0A      %7D%0A    %7D%0A    return false;%0A  %7D%0A%7D%0A

Create the-grid-search.java