If fire started then call fire Service if I saw it burning badly then Run out of the company.take help from outside.

save other people because if we save the people then all those things which are destroyed can be again rebuilt with help of those people talents.in this way we can save life as well as we can set our company status again.

Any factory would have an "ON SITE EMERGENCY PLAn" and each of its members would have been allocated a specific role...so i would follow the role given to me....be it transportation,calling for help or even rescuing.

Call fire service and then save other people

I will run out the company first and while running i will do the fire safety job.

Run out first bcoz each employees tought them how to escape from tough time to rescue thems self in dangerous situation.Even they will be instructed well before get in to the working environment by the organisation.

The question could have been a little more detailed, most of the guys who took up the test could not understand this immediately.

Given a number N, XOR it with N+1 = powers of 2 will give all 0s

@Anonymous. That's not true. 3 in binary is 11 and 4 is 100, if you XOR 011 and 100 you will get 111, not 000. I think you meant to say that all numbers will be 1s.

Show more responses

N xor (N+1) = 2*N + 1

If the least bit is 1, then it is equal to N less than power of 2 if ( n &lt;&lt; 7 ) cout &lt;&lt; "It is one less than power of 2" For example 1 - 0000 0001 3 - 0000 0011 5 - 0000 0101 7- 0000 0111

// the power of two is always has the first bit set to1 and rest all would be set to 0. And one less than power of 2 has all the bits set to 1 except the fist bit. for example 16 = 10000 and 15 = 01111 Now if you do bit operation &amp; on 16 and 15, you get zero. Hence, below is the code. public boolean oneLessPowTwo(int num){ boolean b = false; if(n &amp; n+1 == 0){ b = true; } return b; }

the power of two is always has the first bit set to1 and rest all would be set to 0. And one less than power of 2 has all the bits set to 1 except the fist bit. for example 16 = 10000 and 15 = 01111 Now if you do bit operation &amp; on 16 and 15, you get zero. Hence, below is the code. public boolean oneLessPowTwo(int num){ boolean b = false; if((num &amp; (num+1)) == 0){ b = true; } return b; }

A one line answer to this question is: -1 + 2 to the power of -2 - language binary string prefix + length of binary string for N In Python: 2**(len(bin(511))-3)-1 Simple one line in any language with a function to convert int to binary string.

Puzzle: There are 25 horses and 5 lanes for conducting a race among them. In a minimum of how many races, would be able to find out the 3 fastest horses among them? Assumption: Speed of horses are consistent enough across races.

Given that the summation from 1 -&gt; N = N(N+1)/2, we can use simple math to get a solution in O(n) time. We know that our array is "missing" a number, so it's length "L", is N-1. So we know that the summation for our array if it were not missing the value X could be calculated as N(N+1)/2, or (L+1)(L+2)/2. For a given array with length L, all we need to do is calculate what the expected summation is, iterate over the array and find the actual summation, then calculate the difference. public int findMissingValue(int[] sequence) { int length = sequence.length(); int expectedSum = ((length + 1) * (length + 2)) / 2; int actualSum = 0; for (int i = 0; i &lt; length; i++) { actualSum += sequence[i]; } return expectedSum - actualSum; }

You have an array of length N filled with numbers 1 through N+1 with one number missing. 1. bitwise xor all numbers 1 to N+1 2. bitwise xor all numbers in the array 3. bitwise xor the above two numbers to get the missing number, as duplicates will cancel out If two numbers are missing this approach and the sum approach fail. In this case I can't think of a faster way than sorting the list.

For 2 number missing.. First split up the array into half from first half find the first missing number and second half find the second missing number. If 2 missing numbers are in first half then again divide the first half into 2 half and find it.

Show more responses

Use a bitmap: keys are 1 to N and values are true/false. Iterate over the array and populate the bitmap. Iterate over the bitmap and the missing numbers are those that have the value == false.