Given 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.
Answer / Kundan Kumar
One way to find the missing numbers is by using bit manipulation technique. Create a bit mask with all bits set from 0 to n-1. Perform a bitwise AND operation on the bit mask and the sum of all array elements, then perform bitwise OR operations between the result and each number from 1 to n-1 until two numbers are obtained whose XOR is zero. The two missing numbers are these two numbers. Time complexity is O(n).
| Is This Answer Correct ? | 0 Yes | 0 No |
Who is providing best mainframes online training in Hyderabad
how we can call xml file in java file using Android platform?
1. Consider the following input and generate the object code using single pass assembler. JOHN START 0 USING *,15 L 1,FIVE A 1,FOUR ST 1,TEMP FOUR DC F’4’ FIVE DC F’5’ TEMP DS ‘F END
what is the draw back of Power builder
What is meant by spooling
how will you do destructive read and non destructive read in data queue.....
I am looking for selenium RC online Training in chennai. can any one tell me the best institute
What is the Difference between in memory database and physical database
how to generate dsnless connectivity in j2ee
Find out the list of authorization objects which contains activity as a field? Thanks in advance.
Write a program to find factorial of a number using functions
In OB52 , How to define two open posting period, Like only 5 and 8 posting should be open.. should not open 6 and 7..period..