-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAppendDelete.java
More file actions
73 lines (71 loc) · 1.17 KB
/
AppendDelete.java
File metadata and controls
73 lines (71 loc) · 1.17 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import java.io.*;
import java.util.Scanner;
import java.lang.*;
class AppendDelete
{
public static void main(String[]args)throws IOException
{
BufferedReader venki=new BufferedReader(new InputStreamReader(System.in));
String s=venki.readLine();
String t=venki.readLine();
String S="",T="";
int k=Integer.parseInt(venki.readLine());
int l_s=s.length(),l_t=t.length(),c=0;
int i,flag=0,K=0;
if(l_s>l_t)
{
for(i=0;i<l_t;i++)
S+=""+s.charAt(i);
i=0;
S=S+"1";
t=t+"3";
while(flag!=1)
{
if(S.charAt(i)==t.charAt(i))
c++;
else{
flag=1;
break;}
i++;
}
K=(l_s-c)+(l_t-c);
}
else if(l_s<l_t)
{
for(i=0;i<l_s;i++)
T+=""+t.charAt(i);
i=0;
T=T+"1";
s=s+"3";
while(flag!=1)
{
if(s.charAt(i)==T.charAt(i))
c++;
else{
flag=1;
break;}
i++;
}
K=(l_s-c)+(l_t-c);
}
else if(l_s==l_t)
{
K=l_s;
}
if(k>=K)
{
System.out.println("Yes");
}
else if(k==K)
{
if(k%2==0)
System.out.println("Yes");
else
System.out.println("No");
}
else
{
System.out.println("No");
}
}
}