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.
functiongridSearch($G,$P){// Write your code here$xG=count($G);$yG=strlen($G[0]);$xP=count($P);$yP=strlen($P[0]);for($x=0;$x<=$xG-$xP;$x++){for($y=0;$y<=$yG-$yP;$y++){$matchLines=0;for($i=0;$i<$xP;$i++){if(substr($G[$i+$x],$y,$yP)!==$P[$i])break;$matchLines++;}if($matchLines===$xP)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 my solution