append and delete hackerrank solution in python

Solutions on MaxInterview for append and delete hackerrank solution in python by the best coders in the world

showing results for - "append and delete hackerrank solution in python"
Matteo
21 May 2016
1if __name__ == '__main__':
2    s = input().strip()
3    t = input().strip()
4    k = int(input().strip())
5    min_len = min(len(s), len(t))
6    first_different_index = min_len
7
8    for i in range(min_len):
9        if s[i] != t[i]:
10            first_different_index = i
11            break
12
13    necessary_operations = len(s) + len(t) - 2 * first_different_index
14
15    print("Yes" if k == necessary_operations or (k >= necessary_operations and (k - necessary_operations) % 2 == 0 ) or k >= len(s) + len(t) else "No")