- **C**
(*http://www.go4expert.com/forums/c/*)

- - **Can you give the answer**
(*http://www.go4expert.com/forums/answer-t13589/*)

Can you give the answerGiven an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 2 numbers. Find the missing numbers.
It should be efficient way. means If you can then do it in O(n) |

Re: Can you give the answerTry doing it on paper first. What numbers are missing from { 5 2 8 1 10 3 7 4 }?
How did you work it out? OK, if you looked for 1, then 2, then 3 etc, that's inefficient. Work it out again starting at the first element in the array, looking at each element only once. Hint: You can take notes. For example, how might you keep track of the fact that you've seen a 5 after processing the first element? |

All times are GMT +5.5. The time now is 13:37. |