Code golf: combining multiple sorted lists into a single sorted list

前端 未结 26 1835
余生分开走
余生分开走 2020-12-29 12:42

Implement an algorithm to merge an arbitrary number of sorted lists into one sorted list. The aim is to create the smallest working programme, in whatever language you like.

26条回答
  •  隐瞒了意图╮
    2020-12-29 12:58

    Python, 107 chars:

    def f(l):  
     n=[]  
     for t in l:  
      for i in t: n+=[t]  
     s=[]  
     while n: s.+=[min(n)]; n.remove(min(n))  
     return s  
    

提交回复
热议问题