Programmer interview questions brain teaser and probability
You have 4 bottles each containing pills that weigh 10 grams each and 1 bottle containing pills that weigh 9 grams each, How would you find out the lighter of the 5 bottles by using a Digital Scale just Once?
Hint: He asked to open the bottles and take the pills out, and also grouping them wont work.
Label the 4 bottles A,B,C and D. Take 1 tablet from A , 2 from B , 3 from C and 4 from D and weigh it. if the weight is 99 the lighter bottle is A , if its 98 its from B and so on..
Genius, I can’t come up with this bright answer
As there are 5 bottles instead of 4, so
Label the 5 bottles A,B,C,D and E. Take 1 tablet from A , 2 from B , 3 from C, 4 from D and 5 from E and weigh it. if the weight is 149 the lighter bottle is A , if its 148 its from B and so on..
what about the 5th bottle?
If the weight is 100, then it’s in the 5th.
I misread the question as 4 bottles.. Anyways as many would have guessed,the idea still remains the same as the answer I had first posted..
one q was about calculating the number of rabbits when each generate 2M and 2 F offsprings
Also few questions involved finding patterns after certain rotations. One was a comprehension question and one was on graph theory .
The online assessment test was sent to me a week after I submitted my resume. The questions consisted of analytical reasoning, process mapping, abstract thinking etc. There were a lot of questions involving turning shapes clockwise or counter clockwise in different angles , some other questions involved recognizing type of flowchart. I had one question to count the number of appearances of an alphabet and one counting written number denominations. Each questions took 3minutes. It is fairly okay and I was selected to go forward.
It takes 15 minutes to fill a tank from a tap and 40 minutes to enpty it from the sink . If both are open how long will it take to fill the tank . Capacity of tank is 400 gallons
Could probably assume that the tap flows at a constant volume per time. Can’t assume that for emptying it. That will depend on the water pressure at the outlet, which is dependent upon the geometry of the tank.
Since its a simple math problem, other parameter are supposed to be constant.
Tank capacity doesn’t matter. x/15 – x/40 = 1
multiply by 2
if less than 25 go back, else continue
divide by 3
multiply by 3
Which will produce the greater result?
How would you find the largest value in an array?
You will have to use a temp variable. Assign temp to -999 (assuming there is no negative 999 in the data set or use ascii for this. I am not familiar with ascii conversions). Go through the array comparing each variable with the temp. If array variable is higher, store it into temp. Keep doing this till you reach the end. Your temp has the largest value now.
Pramod’s answer is almost perfect. I would make one change: assign temp the first value of the array.
For a non- programmer, how would you search a linear array for a set of information?
It’s not 8, it’s 7. First group the horses into sets of 5. We can eliminate finishers 4 and 5 in each race. Now race the fastest from each previous heat against each other. Now we have used 6 races so far. We can eliminate all of the horses from the 4th and 5th place horses groups, all but the fastest from the 3rd, the fastest and the runner up from the 2nd and none of the remaining group from the 1st.
Thus we have 3 horses from the 1st place finishers heat, 2 from the 2nd, and 1 from the 3rd. However, we already know that the fastest of the 5 winners is the fastest overall and is in, leaving us with only 5 horses not eliminated.
Race them against each other and take the top 2. You have only used 7 races.
1,2,3,5,7…. what will be the next number in series
11…they are all prime numbers
1 is not prime. Question seems wrong
What if we view this series of number as “non-composite”? then 11 will be valid
How will you find out what has happened in the network if – initially the network speed is 10Mbps but suddenly it drops down to 10Kbps.
I told him we can use traceroute and explained how we can use it. He seemed satisfied with the answer.
They also asked those abstract problem solving type questions. I can’t remember exactly but he mentioned one about two pieces of string of variable cross sectional area and you have to burn them and you have to make it time something. The answer involves lighting both at one end at the start and then lighing the other end of the longer one when the first one finishes. When the long one burns to the middle it’s the time you want.
I guess the question you were referring to was:
You have 2 candles that burn from top to bottom in exactly 1 hr. How will you measure 45 minutes?
Ans: Burn one at both ends and the other at the top simultaneously. The first will burn off in 30 minutes and by that time, the second would be half burnt. When 1st is all gone, light the other end of 2nd too and it’ll take 15 more minutes to burn totally. So total = 30 + 15 = 45
the classic question about two eggs dropping from a 100-floor building
How would you structure the data inside a cell phone (i.e. contacts, emails, sms, etc)?
Books order on a shelf with some specific rules such as : Book A has to be in the middle of Book C and Book D. Which order listed below is not possible?FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!