Comment on Python Multiple Assignment Is a PuzzleComments−kghose12y A = [1, 2, 4, 5, 7] A_s = sorted(A) b = A_s[0] for a in A_s[1:]: if a - b > 1: print b + 1 break else: b = a else: print 'No missing element' Trying to be more Pythonic: def test(l): l_s = sorted(l) print [l0 + 1 for l1, l0 in zip(l_s[1:], l_s[:-1]) if l1 - l0 > 1]−ericfrederich12ySorting is not O(N), at best it is O(NlogN)−abhinavk12yBut the code is not competitive.
Comments
Sorting is not O(N), at best it is O(NlogN)
But the code is not competitive.