Fastest way to create strictly increasing lists in Python

后端 未结 5 2114
南方客
南方客 2021-02-07 09:03

I would like to find out what is the most efficient way to achieve the following in Python:

Suppose we have two lists a and b which are of equa

5条回答
  •  醉酒成梦
    2021-02-07 09:27

    a = [2, 1, 2, 3, 4, 5, 4, 6, 5, 7, 8, 9, 8,10,11]
    b = [1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15]
    print(sorted(set(a)))
    print(sorted(set(b)))
    #[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
    #[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
    

提交回复
热议问题