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.
funcisPatternMatch(grid[]string,rowStart,colStartint,pattern[]string)bool{patternWidth:=len(pattern[0])forrowOffset:=0;rowOffset<len(pattern);rowOffset++{gridRow:=grid[rowStart+rowOffset]gridSubstring:=gridRow[colStart:(colStart+patternWidth)]patternRow:=pattern[rowOffset]ifgridSubstring!=patternRow{returnfalse}}returntrue}funcgridSearch(grid[]string,pattern[]string)string{gridWidth:=len(grid[0])patternWidth:=len(pattern[0])patternHeight:=len(pattern)forgridRow:=0;gridRow<=len(grid)-patternHeight;gridRow++{forgridCol:=0;gridCol<=gridWidth-patternWidth;gridCol++{// Check if current position could be the start of a pattern matchifgrid[gridRow][gridCol]==pattern[0][0]{// Verify there's enough space to check for the patternifisPatternMatch(grid,gridRow,gridCol,pattern){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
Join us
Create a HackerRank account
Be part of a 26 million-strong community of developers
Please signup or login in order to view this challenge
The Grid Search
You are viewing a single comment's thread. Return to all comments →
Here is my solution in Golang