1

Possible Duplicate:
Easy interview question got harder: given numbers 1..100, find the missing number(s)

Given a list (or array) of 97 numbers, each number is unique and between 1 and 100. How to find three missing numbers from the list ? complexity of the algorithm ?

My solution:

 find3missing(int* array)
 {
 int newarray[100] = {0};

 For i = 0 to 99 
  ++newarray[array[i]] ; 

 For i = 0 to 99
If newarray[i] != 1
    Cout << “the missing number is ” << i+1 << endl ;
 }

 O(n).

Any better solutions ?

thanks

Community
  • 1
  • 1
user1002288
  • 4,860
  • 10
  • 50
  • 78

0 Answers0