We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defgridSearch(G,P):# Write your code hererows_number,column_number=len(G),len(G[0])patterns_number,first_pattern_len=len(P),len(P[0])ifpatterns_number>rows_numberorfirst_pattern_len>column_number:return"NO"forrow_iinrange(rows_number):rows_left=rows_number-row_iifrows_left<patterns_number:return"NO"forcol_jinrange(column_number-first_pattern_len+1):ifG[row_i][col_j:col_j+first_pattern_len]==P[0]:matches=[G[row_i+i][col_j:col_j+first_pattern_len]==P[i]foriinrange(patterns_number)]ifall(matches):return"YES"return"NO"
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
The Grid Search
You are viewing a single comment's thread. Return to all comments →
Here is my Python Code: