You are viewing a single comment's thread. Return to all comments →
Here is my Python code! It's probably not the most efficient but I couldn't find any faster algorithms.
def gridSearch(G, P): for row in range(len(G) - len(P) + 1): for col in range(len(G[0]) - len(P[0]) + 1): if G[row][col:col + len(P[0])] == P[0]: found = True for nrow in range(1, len(P)): if G[row + nrow][col: col + len(P[0])] != P[nrow]: found = False break if found: return "YES" return "NO"
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
The Grid Search
You are viewing a single comment's thread. Return to all comments →
Here is my Python code! It's probably not the most efficient but I couldn't find any faster algorithms.