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.
the code works perfectly fine for me ... here is my code
importjava.io.*;importjava.util.*;publicclassSolution{publicstaticvoidmain(String[]args){intt,x,y,x1,y1;Scannerin=newScanner(System.in);Strings;t=Integer.parseInt(in.nextLine());for(inti=0;i<t;i++){s=in.nextLine();Strings1[]=s.split("\\s");x1=Integer.parseInt(s1[0]);y1=Integer.parseInt(s1[1]);inta[][]=newint[x1][y1];for(intj=0;j<x1;j++){s=in.nextLine();Strings3[]=s.split("");for(intk=0;k<y1;k++){a[j][k]=Integer.parseInt(s3[k]);// System.out.println("j is " + j +" and k is " + k + " and val is " +a[j][k]);}}s=in.nextLine();//System.out.println(s);Strings2[]=s.split("\\s");x=Integer.parseInt(s2[0]);y=Integer.parseInt(s2[1]);intb[][]=newint[x][y];for(intj=0;j<x;j++){s=in.nextLine();Strings4[]=s.split("");for(intk=0;k<y;k++){b[j][k]=Integer.parseInt(s4[k]);}}intr,c=0,count=y,dup=0,dup1=0,er1=0,er2=0,br=0,crt=0,j1=0,k1=0;for(intj=0;j<x1;j++){for(intk=c;k<y1;k++){// System.out.print("here j is "+j+" and k is "+k + "and y1 is "+ y1);//System.out.println(a[j][k]+" and " + b[j1][k1]);if(a[j][k]==b[j1][k1]){//System.out.print("here j1 is "+j1+" and k1 is "+k1 + "and y1 is "+ y1);if(dup1==0){c=k;er1=j;er2=k;dup1++;}k1++;if(k1>y){j1++;k1=0;}dup++;//dup1++;}else{if(dup1!=0){j=er1;k=er2;// System.out.println("Location Changed ");}dup1=0;dup=0;c=0;crt=0;j1=k1=0;}if(dup==count){//System.out.println("here");crt++;if(crt==x){br=1;break;}dup=0;//dup1=0;j1++;k1=0;break;}}if(br==1)break;}if(br==1)System.out.println("YES");elseSystem.out.println("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 →
the code works perfectly fine for me ... here is my code