Data Structure & Algorithm: Level-1 Problem #3. Find Missing Numbers

Given a list of numbers, each number is no more than the length of the list. For example, if the length of the list is N, the value of each element in the list is between 1 and N. Some numbers may be duplicated, some numbers may be missing. Compared with numbers 1 to N, find out the missing numbers in the list.

Sample Input:

2, 3, 3, 5, 5, 5, 6, 7, 8

Sample Output:

1, 4, 9

In the above sample input, there are 9 numbers in total. Compared with number 1 to 9, the missing numbers are 1, 4 and 9.


数据结构和算法:初级练习题# 3 – 寻找缺失的数字


给定一组数字,每个数字都不超过该组的长度。譬如一组N个数字,那么每个数字都在1和N之间,有些数字会重复,有线数字会缺失。对比数字1到N,请从这组数字中找出缺失的数字。

输入样例:

2, 3, 3, 5, 5, 5, 6, 7, 8

输出样例:

1,4, 9

在上面的输入样例中,总共有9个数字。对比数字1到9,该组数字里面缺失的是 1, 4 ,9。


Python Solutions (4 in total)

Find Missing Numbers