Skip to content

Commit cb35bba

Browse files
author
shiv
committed
added code for interleaved strings in python
1 parent 101ea31 commit cb35bba

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

ip.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
1
2-
6
3-
10 5 50 1 40 100
4-
5 45
1+
2
2+
YX X XXY
3+
XY X XXY

str_interleaving.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SHIV's code for string interleaving
2+
3+
'''
4+
2
5+
YX X XXY
6+
XY X XXY
7+
'''
8+
9+
tn = int(input())
10+
11+
def process(a, b, c):
12+
left = []
13+
if len(a) > len(b):
14+
left = a[len(b):]
15+
C = [x+y for x,y in zip(a[:len(b)], b)]
16+
elif len(b) > len(a):
17+
left = b[len(a):]
18+
C = [x+y for x,y in zip(a, b[:len(a)])]
19+
if ''.join(C)+left == c: return True
20+
return False
21+
22+
for i in range(tn):
23+
a, b, c = input().split()
24+
print(process(a, b, c))

0 commit comments

Comments
 (0)