-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChef_and_Two_Strings.java
More file actions
28 lines (27 loc) · 892 Bytes
/
Chef_and_Two_Strings.java
File metadata and controls
28 lines (27 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.Scanner;
public class Chef_and_Two_Strings {
public static void main(String[] args) {
Scanner sn = new Scanner(System.in);
int tc = sn.nextInt();
while(tc-->0){
String a = sn.next();
String b = sn.next();
int qA = 0, qB =0;
for(int i =0; i< a.length(); i++){
if(a.charAt(i) == '?') qA++;
if(b.charAt(i) == '?') qB++;
}
int finalQ = (int) Math.max(qA,qB);
int same = 0;
for(int i =0; i< a.length(); i++){
if(a.charAt(i) != '?' || b.charAt(i) != '?'){
if(a.charAt(i) == b.charAt(i)) same++;
}
}
int max = same + finalQ;
int min = same ;
System.out.print(min+ " ");
System.out.println(max);
}
}
}