• + 0 comments

    Here is my solution in Python: def gridSearch(G, P): R,C = len(G),len(G[0]) r,c = len(P),len(P[0]) for i in range(C-c+1): for j in range(R-r+1): #If the first element is correct, start to check: if G[j][i] == P[0][0]: check = True for k in range(r): for l in range(c): if G[j+k][i+l] != P[k][l]: check = False if check == False: break I don't know a smarter way for this problem so I just brute force

    I if check == True:
                    return "YES"
    return "NO"