Suppose we have two items missing in a sequence of consecutive integers and the missing elements lie between the first and last elements. I did write a code that does accomp
a=[1,2,3,7,5,11,20] b=[] def miss(a,b): for x in range (a[0],a[-1]): if x not in a: b.append(x) return b print (miss(a,b))
ANS:[4, 6, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19]
[4, 6, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19]
works for sorted,unsorted , with duplicates too
sorted
unsorted
duplicates