Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package repairroad;
- import java.util.Scanner;
- import java.util.Arrays;
- public class RepairRoad
- {
- public static void main(String[] args)
- {
- Scanner mk= new Scanner(System.in);
- String n= mk.next();
- String m=mk.next();
- int k= n.length();
- int t= m.length();
- if(k !=t)
- {
- System.out.print("(s1,s2)= false"); return;
- }
- String []A= new String[k];
- String []B= new String[t];
- for(int i=0; i< k;i++)
- {
- A[i]= n.substring(i, i+1);
- }
- for(int i=0;i < t;i++)
- {
- B[i]= m.substring(i, i+1);
- }
- int count =0;
- String r= "?";
- int i=0;
- while(i<k)
- {
- if(A[i].equals(r) ) count++;
- else
- {
- for(int j=0;j<t;j++)
- {
- if(A[i].equals(B[j]))
- {
- count ++;
- B[i]="";
- A[i]="";
- }
- }
- }
- i++;
- }
- if(count >=t)
- {
- System.out.print("(s1,s2)= true");
- }
- else
- {
- System.out.print("(s1,s2)= false");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement