-
-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathAppendandDelete.java
38 lines (35 loc) · 966 Bytes
/
AppendandDelete.java
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
29
30
31
32
33
34
35
36
37
38
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);
char s[] = in.next().toCharArray();
int s1 = s.length;
char t[] = in.next().toCharArray();
int t1 = t.length;
int k = in.nextInt();
int contM = 0;
for(int i=0;i<Math.min(s1,t1);i++) {
if(s[i]==t[i]){
contM++;
} else{
break;
}
}
String ans = "No";
int op1 = s1-contM;
int op2 = t1-contM;
if(k==(op1+op2))
ans = "Yes";
else if(k<(op1+op2))
ans = "No";
else if(((k-(op1+op2))/2 < contM) && (((k-(op1+op2))%2)==0))
ans = "Yes";
else if(k>(s1+t1))
ans = "Yes";
System.out.println(ans);
}
}