Skip to content
Snippets Groups Projects
Select Git revision
  • 101b3fc5a025db67d98329b31da3e68dc393928f
  • master default protected
2 results

bfs.py

Blame
  • 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]