Select Git revision
-
Romain Vuillemot authoredRomain Vuillemot authored
listes-fusion.py 367 B
def fusion(l1, l2):
res = []
i = 0
j = 0
while i < len(l1) and j < len(l2):
if l1[i] < l2[j]:
res.append(l1[i])
i += 1
else:
res.append(l2[i])
j += 1
while i < len(l1):
res.append(l1[i])
i += 1
while j < len(l2):
res.append(l2[j])
j += 1
return res
print(fusion([2, 2, 3], [0, 4, 5, 14, 20, 25]))
# [0, 2, 2, 3, 4, 5, 14, 20, 25]