Monday, October 24, 2016

What is the toughest question ever asked in any interview?



https://www.quora.com/What-is-the-toughest-question-ever-asked-in-any-interview
This question was asked to one of my friends in his campus placement interview with Microsoft.
Interviewer: Ok, so one last question. A right triangle has a hypotenuse equal to 10 and an altitude to the hypotenuse equal to 6. Find the area of the triangle

My friend started thinking 'Why would a software company ask a geometry question and that too such a trivial one! Maybe it is a trick question!? Maybe it isn't a trick question and he just wants me to think otherwise so that I would screw up even this paltry question!?'
He contemplated for a while and answered:
Friend: Sir, as area of any triangle is 0.5*base*height, the answer to this question would be 0.5 *10*6 which evaluates to 30!
Interviewer: Are you sure? Think about it again!
*My friend thought for a while and replied with full confidence*
Friend: Yes sir, I am sure the area of triangle is 30. You are just messing up with my brain to make me think otherwise so that I would commit error even in this trivial question.
(This was the exact response which my friend gave to the interviewer!)
Interviewer: Well, your answer is wrong XYZ, and that was the last question of this interview. You can wait outside until we declare the results.
Friend: Sir, could you please tell me what's the correct answer?
Interviewer: The correct answer is, such a triangle cannot exist. If you think about it, you will come to know why!
And my friend left the room dumbfounded, still thinking about why that triangle cannot exist.
Verdict: He wasn't selected!
----------------------------------------------------------------------------------------------
Here's the solution: It turns out that the maximum length of the altitude to hypotenuse in the above triangle can only be 5 and not 6, so its maximal area would be 25.
The angle opposite the hypotenuse must be a right angle of 90 degrees. This means the two sides of the triangle must subtend a 180 degree angle in a circle. The hypotenuse must be the diameter of a circle, and the third point can be any point on the circle (except the endpoints of the hypotenuse).


The vertical distance from the third point to the hypotenuse is the altitude to the hypotenuse. This is largest when the third point is at the top or bottom of the circle, and the vertical distance is equal to the radius of the circle (half the length of the hypotenuse, which is the diameter of the circle).


Therefore, a right triangle with a hypotenuse of 10 can have an altitude on its hypotenuse of at most 5.
I would say it was one of the most difficult questions to answer because the hard question was very well disguised as a trivial question. And although it seemed quite strange that a software giant like Microsoft asked a geometry question, it wasn't strange at all. The real motive could have been to check whether the candidate has good analytical skills and levelheadedness, both of which are quite essential in the programming world.

After all the confusion, I must make it clear that altitude to the hypotenuse is given as 6
EDIT1: With a little thinking outside of the box, Job Bouwman showed that such a triangle may actually exist, although (according to his own words) you take a risk of coming across as a smart-ass...
EDIT2: I just stumbled upon a question which too was probably asked in a Microsoft interview(not sure) and I thought it would be nice to share it with you people. Here’s the link:

This incident took place with one of my friends during an interview for a technical position.
I- Interviewer, C- Candidate
I: There is a circular race-track of diameter 1 km. Two cars A and B are standing on the track diametrically opposite to each other. They are both facing in the clockwise direction. At t=0, both cars start moving at a constant acceleration of 0.1 m/s/s (initial velocity zero). Since both of them are moving at same speed and acceleration and clockwise direction, they will always remain diametrically opposite to each other throughout their motion.
At the center of the race-track there is a bug. At t=0, the bug starts to fly towards car A. When it reaches car A, it turn around and starts moving towards car B. When it reaches B, it again turns back and starts moving towards car A. It keeps repeating the entire cycle. The speed of the bug is 1 m/s throughout.
After 1 hour, all 3 bodies stop moving. What is the total distance traveled by the bug?
How would you, the reader, approach this problem?
First of all here is a graphic to help you visualize initial condition.
Now, let’s try to visualize the path of the bug. The question states that it will always be moving towards one of the cars. But the cars themselves are moving. So, bug’s path would not be a straight line. It would be a complicated spiral like path. Plus, the cars are not moving at constant velocity. They are accelerating, this will further complicate the spiral path.
So, the approach is clear. We need to find mathematical equation corresponding to bug’s path for one cycle. Then we can simply calculate the distance from this equation and a little integral calculus. Then multiply the answer with the number of cycles.
But how to calculate the equation of the complicated spiral path?
At this point my friend simply gave up.
The interviewer encouraged him to at least tell his approach. My friend explained above approach.
At this interviewer replied - “Are you ready to hear my solution?”
My friend was more than eager.
The interviewer said - “Bug is traveling at a constant speed of 1 m/s throughout it’s motion. At this constant speed, he travels for 1 hour. So distance = speed x time = 1 m/s x 3600s = 3.6 km.”

My thoughts -
I think this question (and its solution) provides a profound description of life itself. Most of the times, we face situations that seem hopelessly complicated. There seems to be no way out.
But once you hack away the outer layers - parts that are unimportant, parts that are irrelevant to the final solution, parts that are only present there to complicate the situation, you reach the core. And the core is beautiful, with an elegance that is signified by its sheer simplicity.

Some people are asking for further explanation.
What happened here is that the question provided a lot of details about the complicated interconnected motion of the three bodies. But all of that information is irrelevant to calculate the final answer. The only important statement in the question that you have to identify is, “The speed of the bug is 1m/s throughout”. This is the core. Once you identify that it’s speed was constant throughout, the actual path the bug took becomes irrelevant. No matter how complicated that path was, the total distance would be still given by the simple equation “distance = speed x time”
That was the real challenge. To be able to see through the outer layers and get to the core. That ability is what the interviewer was looking for.

http://www.mytechinterviews.com/globe-walker
Question: How many points are there on the globe where, by walking one mile south, then one mile east and then one mile north, you would reach the place where you started?
Answer: The trivial answer to this question is one point, namely, the North Pole. But if you think that answer should suffice, you might want to think again! :)
Let’s think this through methodically. If we consider the southern hemisphere, there is a ring near the South Pole that has a circumference of one mile. So what if we were standing at any point one mile north of this ring? If we walked one mile south, we would be on the ring. Then one mile east would bring us back to same point on the ring (since it’s circumference is one mile). One mile north from that point would bring us back to the point were we started from. If we count, there would be an infinite number of points north of this one mile ring.
So what’s our running total of possible points? We have 1 + infinite points. But we’re not done yet!
Consider a ring that is half a mile in circumference near the South Pole. Walking a mile along this ring would cause us to circle twice, but still bring us to back to the point we started from. As a result, starting from a point that is one mile north of a half mile ring would also be valid. Similarly, for any positive integer n, there is a circle with radius
r = 1 / (2 * pi * n)
centered at the South Pole. Walking one mile along these rings would cause us to circle n times and return to the same point as we started. There are infinite possible values for n. Furthermore, there are infinite ways of determining a starting point that is one mile north of these n rings, thus giving us (infinity * infinity) possible points that satisfy the required condition.
So the real answer to this question is 1 + infinity * infinity = infinite possible points!

Labels

Review (572) System Design (334) System Design - Review (198) Java (189) Coding (75) Interview-System Design (65) Interview (63) Book Notes (59) Coding - Review (59) to-do (45) Linux (43) Knowledge (39) Interview-Java (35) Knowledge - Review (32) Database (31) Design Patterns (31) Big Data (29) Product Architecture (28) MultiThread (27) Soft Skills (27) Concurrency (26) Cracking Code Interview (26) Miscs (25) Distributed (24) OOD Design (24) Google (23) Career (22) Interview - Review (21) Java - Code (21) Operating System (21) Interview Q&A (20) System Design - Practice (20) Tips (19) Algorithm (17) Company - Facebook (17) Security (17) How to Ace Interview (16) Brain Teaser (14) Linux - Shell (14) Redis (14) Testing (14) Tools (14) Code Quality (13) Search (13) Spark (13) Spring (13) Company - LinkedIn (12) How to (12) Interview-Database (12) Interview-Operating System (12) Solr (12) Architecture Principles (11) Resource (10) Amazon (9) Cache (9) Git (9) Interview - MultiThread (9) Scalability (9) Trouble Shooting (9) Web Dev (9) Architecture Model (8) Better Programmer (8) Cassandra (8) Company - Uber (8) Java67 (8) Math (8) OO Design principles (8) SOLID (8) Design (7) Interview Corner (7) JVM (7) Java Basics (7) Kafka (7) Mac (7) Machine Learning (7) NoSQL (7) C++ (6) Chrome (6) File System (6) Highscalability (6) How to Better (6) Network (6) Restful (6) CareerCup (5) Code Review (5) Hash (5) How to Interview (5) JDK Source Code (5) JavaScript (5) Leetcode (5) Must Known (5) Python (5)

Popular Posts