May-07-2019, 04:26 AM
Find missing number position / index based on the input
Here is the sample data.
Output 1,2,3,4,5,6,7,8,9,10
Index 0,1,2,3,4,5,6,7,8,9
Here is the sample data.
def missing_numbers(num_list):
original_list = [x for x in range(num_list[0], num_list[-1] + 1)]
num_list = set(num_list)
return (list(num_list ^ set(original_list)))
missing_numbers([1,2,3,4,6,7,10])
[5, 8, 9]
>>>it returns 5 ,8,9, but how to say that the it is missing in the index of 4,7,8.Output 1,2,3,4,5,6,7,8,9,10
Index 0,1,2,3,4,5,6,7,8,9
