-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAppend and Delete.py
More file actions
48 lines (34 loc) · 827 Bytes
/
Append and Delete.py
File metadata and controls
48 lines (34 loc) · 827 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'''
Problem Statement: https://www.hackerrank.com/challenges/append-and-delete/problem
@Coded by TSG,2020
'''
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the appendAndDelete function below.
def appendAndDelete(s, t, k):
S=list(s)
T=list(t)
m,mm=len(S),len(T)
min_len=min(m,mm)
c = min_len
for i in range(c):
if S[i] != T[i]:
break
c=i
op = m + mm - (2 * c)
if ((k == op) or (k >= len(s) + len(t)) or (k >= op and (k - op) % 2 == 0)):
return ("Yes")
else:
return("No")
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
s = input()
t = input()
k = int(input())
result = appendAndDelete(s, t, k)
fptr.write(result + '\n')
fptr.close()