You are viewing a single comment's thread. Return to all comments →
Hi, I used Pattern Matching for this its complexity is very good but only 5th test case giving wrong answer all others are fine. This is my code :-
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for(int a0 = 0; a0 < t; a0++){ int R = in.nextInt(); int C = in.nextInt(); String G[] = new String[R]; for(int G_i=0; G_i < R; G_i++){ G[G_i] = in.next(); } int r = in.nextInt(); int c = in.nextInt(); String P[] = new String[r]; for(int P_i=0; P_i < r; P_i++){ P[P_i] = in.next(); } StringBuilder sb = new StringBuilder(); StringBuilder sb1 = new StringBuilder(); StringBuilder sb2 = new StringBuilder(); for(int i=0;i<R;i++){ sb.append(G[i]); } for(int i=0;i< C-c ;i++){ sb1.append("."); } sb2.append(".*"); for(int i=0;i< r ;i++){ sb2.append(P[i]); if(i< r-1){ sb2.append(sb1.toString()); } } sb2.append(".*"); if(sb.toString().matches(sb2.toString())){ System.out.println("YES"); } else{ System.out.println("NO"); } } }
}
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 →
Hi, I used Pattern Matching for this its complexity is very good but only 5th test case giving wrong answer all others are fine. This is my code :-
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
}