My Text

It is the wisdom of man to sacrifice for his fellow man, in a wise manner

Thursday, August 15, 2019

Tech Job Brain Teasers

Tech engineers are some of the smartest people in the world.
But even they have a hard time answering the brain teaser questions a lot of tech companies like to ask during job interviews.
We went through Glassdoor to find some of the trickiest brain teaser questions they get asked, and the best way to answer them.

Systems engineer at Google: "How many trailing zeros are in the number 5! (5 factorial)?"

Business Insider / Jillian D'Onfro
Suggested answers:
"5!=120. So there is 1 trailing zero."
"This sounds like one geared not so much towards getting the right answer, but getting to it the right way. If you think a bit and say "one", the interviewer will know you did it the brute-force way, doing the math. You'd get at the answer faster, and probably impress them more, if you think instead how many times a ten will be produced in doing that math, rather than what the actual result of the math will be."

Answer like a real Silicon Valley Engineer!!! Most engineers and tech leaders who now shape the way we use our technology can be found in the Silicon Valley. They are in Apple, Facebook, and Google, to mention a few of the many startups and global tech companies located in the southern San Francisco Bay Area of California. But before people get to be hired as part of these tech think tanks, they undergo a rigorous process to prove themselves worthy of a Silicon Valley job. 
Part of that process is to answer bizarre brain teasers to test the thinking abilities of prospective hires. They range from basic, tricky, to difficult which measure the logic of engineers. Listed below from MyCareerStacks are 5 of such brain teasers coming from multiple companies, and 9 others complete with answers. If you plan to be part of any of the Silicon Valley companies, these are worth a mental exercise. 

Company: Adobe Can you answer like a real Silicon Valley engineer… an Adobe engineer? There are 50 bikes with a tank that has the capacity to go 100 kms. Using these 50 bikes, what is the maximum distance that you can go? 
Answer: Source: Giphy The most naive solution would be to just make all the bikes go together, but sadly you cannot go further than 100kms using that approach. There is another solution to this that can cover 350kms. Move the bikes 50kms so that each bike has half-tank empty. Now pour the fuel from half the bikes to the other half so that they are all full. Now you have 25 bikes with full tanks and then you again repeat the trick. This way you can go 50, 25, 12, 6, 3, and 1 to cover 5*50 = 250kms. That’s 350kms in total. 

Company: Microsoft Can you answer like a real Silicon Valley engineer… a Microsoft engineer? If you had an infinite supply of water and a 5-liter and 3-liter bucket, how would you measure exactly 4 liters? The buckets do not have any intermediate scales. 
Answer: It is a classic puzzle with a simple answer. Fill the 5-liter bucket and empty it in the 3-liter bucket. Now you have 2 liters in the bigger bucket and 3 in the other. Empty the 3-liter bucket and pour the 2 liters from the bigger bucket into it. Now fill the 5-litre bucket completely, and pour water from it to the smaller bucket. Since the smaller bucket already has 2 liters, it can only take 1 more. This leaves us with 4 liters in the 5-liter bucket. 

Company: Google Can you answer like a real Silicon Valley engineer… a Google engineer? The probability of finding the parking slot occupied is 1/3. You find it empty for 9 consecutive days. Find the probability that it will be empty on the 10th day. 
Answer: Sometimes, there is trick with probability questions; but more often, there is none. Always go for the logical answer to questions like this one. The answer to this is 2/3, because it says about the probability of finding it empty on the 10th day. In probability, if an event has already happened, it cannot have an effect on the probability of an event to occur in the future. So the parking slot has been empty for 9 days but that does not affect the 10th day. 

Company: Amazon Can you answer like a real Silicon Valley engineer… an Amazon engineer? Read more  Scientists Turn Soybean Oil Into a Material 200 Times Stronger Than Steel You toss two coins. If you get heads with the first coin, you stop. If you get tails, you toss it again. The second coin is tossed regardless. What is the ratio of heads to tails? Answer: Since you’re only expected to toss the first coin twice — given a 50/50 chance of getting heads — the ratio is 1 to 1. The second coin is also continuously tossed, and has a ratio of 1 to 1. So, the whole ratio is still 1 to 1. Company: Microsoft Can you answer like a real Silicon Valley engineer… a Microsoft engineer? You’re given a pair of tic-tac-toe boards. Find a way to determine, when rotated, that they are the same board. Answer: With your tic-tac-toe boards, you can rotate them left or right four times, and then mirror it and do the same again. So, the way to do this is to reduce it down to a matrix and then rotate it, one step at a time, to check if it matches another board. Mathematically, the way to do this is to turn it into a three-by-three matrix, and then flip the rows and columns. If you want to rotate it to the right, switch the columns, and to rotate it left, switch the rows.

Read more at: https://gineersnow.com/leadership/can-answer-brain-teasers-prospective-engineers-silicon-valleyese tech think tanks, they undergo a rigorous process to prove themselves worthy of a Silicon Valley job. Part of that process is to answer bizarre brain teasers to test the thinking abilities of prospective hires. They range from basic, tricky, to difficult which measure the logic of engineers. Listed below from MyCareerStacks are 5 of such brain teasers coming from multiple companies, complete with answers. If you plan to be part of any of the Silicon Valley companies, these are worth a mental exercise. Company: Adobe Can you answer like a real Silicon Valley engineer… an Adobe engineer? There are 50 bikes with a tank that has the capacity to go 100 kms. Using these 50 bikes, what is the maximum distance that you can go? Answer: Source: Giphy The most naive solution would be to just make all the bikes go together, but sadly you cannot go further than 100kms using that approach. There is another solution to this that can cover 350kms. Move the bikes 50kms so that each bike has half-tank empty. Now pour the fuel from half the bikes to the other half so that they are all full. Now you have 25 bikes with full tanks and then you again repeat the trick. This way you can go 50, 25, 12, 6, 3, and 1 to cover 5*50 = 250kms. That’s 350kms in total. Read more  This Is The Show Elon Musk Doesn’t Think Portrays Silicon Valley Correctly Company: Microsoft Can you answer like a real Silicon Valley engineer… a Microsoft engineer? If you had an infinite supply of water and a 5-liter and 3-liter bucket, how would you measure exactly 4 liters? The buckets do not have any intermediate scales. Answer: It is a classic puzzle with a simple answer. Fill the 5-liter bucket and empty it in the 3-liter bucket. Now you have 2 liters in the bigger bucket and 3 in the other. Empty the 3-liter bucket and pour the 2 liters from the bigger bucket into it. Now fill the 5-litre bucket completely, and pour water from it to the smaller bucket. Since the smaller bucket already has 2 liters, it can only take 1 more. This leaves us with 4 liters in the 5-liter bucket. Company: Google Can you answer like a real Silicon Valley engineer… a Google engineer? The probability of finding the parking slot occupied is 1/3. You find it empty for 9 consecutive days. Find the probability that it will be empty on the 10th day. Answer: Sometimes, there is trick with probability questions; but more often, there is none. Always go for the logical answer to questions like this one. The answer to this is 2/3, because it says about the probability of finding it empty on the 10th day. In probability, if an event has already happened, it cannot have an effect on the probability of an event to occur in the future. So the parking slot has been empty for 9 days but that does not affect the 10th day. Company: Amazon Can you answer like a real Silicon Valley engineer… an Amazon engineer? Read more  Scientists Turn Soybean Oil Into a Material 200 Times Stronger Than Steel You toss two coins. If you get heads with the first coin, you stop. If you get tails, you toss it again. The second coin is tossed regardless. What is the ratio of heads to tails? Answer: Since you’re only expected to toss the first coin twice — given a 50/50 chance of getting heads — the ratio is 1 to 1. The second coin is also continuously tossed, and has a ratio of 1 to 1. So, the whole ratio is still 1 to 1. Company: Microsoft Can you answer like a real Silicon Valley engineer… a Microsoft engineer? You’re given a pair of tic-tac-toe boards. Find a way to determine, when rotated, that they are the same board. Answer: With your tic-tac-toe boards, you can rotate them left or right four times, and then mirror it and do the same again. So, the way to do this is to reduce it down to a matrix and then rotate it, one step at a time, to check if it matches another board. Mathematically, the way to do this is to turn it into a three-by-three matrix, and then flip the rows and columns. If you want to rotate it to the right, switch the columns, and to rotate it left, switch the rows.

Read more at: https://gineersnow.com/leadership/can-answer-brain-teasers-prospective-engineers-silicon-valley

Software engineer at Facebook: “You have two lightbulbs at a 100-story building. You want to find the floor at which the bulbs will break when dropped. Find the floor using the least number of drops.”

Flickr / Jackman Chiu
Suggested answers:
"Start moving up in increments of 10 floors and dropping the bulb until it breaks (ie: drop from floor 10, if it doesn't break, drop from floor 20, etc.). Once the bulb breaks, move down to the floor before it broke on and start moving up floors in increments of one until the second bulb breaks. This results in a worst case scenario of 19 drops."
"19 drops is not the best worst case scenario... imagine trying floor 16, if it breaks, you try 1 - 15 and thats 16 tries. If it doesn't break, then try floor 31 and if it breaks, then try 17 - 30 (so 16 tries, including the try on floor 16). And on and on (45, 58, 70, 81, 91, 100). If you reach 91, you'll have tried 7 floors so far and if it doesn't break, then there's 9 more tries to get to 100 (thus 16 in the worst case)."

Manager at Amazon: “If you had 5,623 participants in a tournament, how many games would need to be played to determine the winner?”

John Ferry/Getty Images
Suggested answers:
"The interviewer is not looking for the right answer because there can be many. What he/she is looking for is your logical approach in solving the answer. So you could start by probing more is first I would like to understand if 5,623 participants represent the number of team or individuals. Then ask the next logical question based on the answer."
"5,622. Assuming it is a single elimination tournament. All teams lose one game except the champs. It's always # of teams - 1."

Software Development Engineer in Test at Webtrends: "There are 20 different socks of two types in a drawer in a completely dark room. What is the minimum number of socks you should grab to ensure you have a matching pair?"

Shutterstock
Suggested answer:
"I'm not a mathematician, statistician, or highly analytical but if you pick up 3 socks they could still be all the same type - even if the odds are 50%. Odds do not equal reality. So the only way to 'ensure you have a matching pair' is to pick up 11 of the 20. This is the only fool proof guaranteed way to get a pair (in the real world and not the world of odds)."

Web Technology Intern at Riot Games: “Imagine that you have three boxes, one containing two black marbles, one containing two white marbles, and the third, one black marble and one white marble. The boxes were labeled for their contents - BB, WW, BW - but someone has switched the labels so that every box is now incorrectly labeled. You are allowed to take one marble at a time out of any box, without looking inside, and by this process of sampling you are to determine the contents of all three boxes. What is the smallest number of drawings needed to do this?”

Ilike
Suggested answer:
"The key thing here is that the box does not contain what it says on the label. As such you can guarantee the contents of each box with one draw. Here's how: Draw a marble from the box labeled BW (since it is labeled BW it must be either BB or WW) If you draw a white for example you know 100% that it is the WW box. Then there are only two boxes left labeled WW and BB in this example and the only two things that they can be are BB or BW. The box labeled BB cannot be BB and so hence must be the BW. This leaves the box labeled WW to be BB by elimination. Same thing works if you pick a black marble first. The key is picking from the BW box in the start and confirming what it actually is. One draw is the smallest number needed."

Software Engineer at Cisco: "If you have a square room with no roof, and you had four flagpoles you had to plant on the walls so that each flagpole touched two walls, how would you do it?"

flickr/audio_technica
Suggested answer:
"The answer was that by planting them on the corners, each one is touching two walls because each corner is part of two walls. I wanted to pierce two walls with a pole horizontally too. They said it was an innovative solution."

Software engineer at D. E. Shaw & Co.: "Given 9 balls all of which weigh the same except for one, what is the minimum of weighings necessary to find the ball weighs more (or less)?"

Wikimedia Commons
Suggested answer:
"You could do this with two weighings assuming its a two pan balance - (1) place three balls on each side - if they balance out then its the remaining three that has abnormal ball (2) out of that group, place one ball on each side - if balances it out, the abnormal ball is the remaining one. If the weighing in step (1) does not balance out, grab the group of three balls that is light or heavy and repeat step (2) described above."

ASIC Verification engineer at Zoran: "You have 2 pieces of rope, each of which burns from one end to the other in 30 minutes (no matter which end is lit). If different pieces touch, the flame will transfer from one to the other. You cannot assume any rope properties that were not stated. Given only 1 match, can you time 45 minutes?"

Aly Weisman/Business Insider
Suggested answers:
"Take one rope (Rope A), place it down as a circle. Light match and start burning rope A at the tips that are touching. When the rope completely burns out, 15 minutes will have passed (since both ends are burning and being consumed at once). Hold the second rope (Rope B) straight and place one end so that it will immediately catch fire when the two burning points from (Rope A) finally touch and are just about to burn out. Thus 15 minutes on Rope A + 30 minutes on Rope B gives you 45 mins."
"Make a T. Simple."

Software engineer at Raytheon: "In front of you are three light switches. Only one does anything, and it turns on the light downstairs. From here you can't see the light, and it makes no sound. You must determine which switch operates the light, BUT you can only go check it once. How do you figure out which switch is for the light?"

Flickr / Sputnik Mania
Suggested answer:
"Flip any switch you want. Wait for about 5-10 minutes to let the bulb heat up. Flip that same switch off, and another one on. Go check the light. If it's off and hot, it was the first switch, if it's on it was the second and if it's cold and off, it was the last one."