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 herei=0whilei<len(G):pattern="".join(P[0])gridline="".join(G[i])prevPatternIndex=0whilepatterningridline[prevPatternIndex:]:indexOfPattern=gridline.index(pattern,prevPatternIndex)j,k=0,iwhilej<len(P)andk<len(G)and"".join(G[k])[indexOfPattern:].startswith("".join(P[j])):k+=1j+=1ifj==len(P):return"YES"prevPatternIndex+=1i+=1return"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 →