Assume we need to look for the following 2D pattern array:
The 2D pattern begins at the second row and the third column of the grid. The pattern is said to be present in the grid.
Complete the gridSearch function in the editor below. It should return YES if the pattern exists in the grid, or NO otherwise.
gridSearch has the following parameter(s):
G: the grid to search, an array of strings
P: the pattern to search for, an array of strings
The first line contains an integer , the number of test cases.
Each of the test cases is represented as follows:
The first line contains two space-separated integers and , indicating the number of rows and columns in the grid .
This is followed by lines, each with a string of digits representing the grid .
The following line contains two space-separated integers, and , indicating the number of rows and columns in the pattern grid .
This is followed by lines, each with a string of digits representing the pattern .
Display YES or NO, depending on whether is present in .