# Preguntas de entrevistas para Intern

# 134 k

Preguntas de entrevista para Intern compartidas por los candidatos## Preguntas de entrevista principales

### Suppose you had eight identical balls. One of them is slightly heavier and you are given a balance scale . What's the fewest number of times you have to use the scale to find the heavier ball?

48 respuestas↳

Two. Split into three groups of three, three, and two. weigh the two groups of three against each other. If equal, weigh the group of two to find the heavier. If one group of three is heavier pick two of the three and compare them to find the heaviest. Menos

↳

2 3a+3b+2 = 8 if wt(3a)==wt(3b) then compare the remaining 2 to find the heaviest if wt(3a) !== wt(3b) then ignore group of 2 discard lighter group of 3 divide the remaining group of 3 into 2+1 weigh those 2 If == the remaing 1 is the heaviest if !== the heaviest will be on the scale Menos

↳

2 weighings to find the slightly heavier ball. Step 1. compare 2 groups of three balls. Case 1. if they are both equal in weight, compare the last 2 balls - one will be heavier. case 2. If either group of 3 balls is heavier, take 2 balls from the heavier side. compare 1 ball against the 2nd from the heavy group result 1. if one ball is heavier than the other, you have found the slightly heavier ball. result 2. if both balls are equal weight, the 3rd ball is the slightly heavier ball. Easy Shmeezi Menos

### How many different ways can you get water from a lake at the foot of a mountain, up to the top of the mountain?

28 respuestas↳

Jesus guys. You're interviewing for DISNEY! Use some imagination. My favorite so far is people power. Set up a huge rotating conveyor belt with small buckets on it, that dip into the lake. A person hops on at the top, and rides it down. This would be great if all the jobs were at the bottom, or if they needed t odo something else at the bottom. It would be fun too! Other ways might be to boil it yourself! dig under a section of lake and start a huge fire with a big condenser tube over it. Have the tube curly cue all the way to the top of the mountain, condense up there, then drip out as nice cool, distilled water. Use your imagination. Be creative. None of you would have been hired for this job. Menos

↳

It's Disney... CGI effects! The water doesn't really get there, it just looks amazing to the public. Menos

↳

I would borrow the sorcerer's hat, find all the brooms he left laying around and reanimate them to carry buckets of water up the mountain. It would be magical! Menos

### Find the max value in an array. The array is "semi-sorted". Here is an example: { 1 3 4 7 9 10 12 13 12 6 3 } As you can see, the array increases and then decreases at one point (13).

19 respuestas↳

Brute force solution can be ofcourse O(N). But we can make it better: mid = (start + end )/2 if mid > mid + 1 && mid > mid - 1 return mid else if mid mid -1 search mid -> end else if mid > mid + 1 && mid mid Menos

↳

It is necessary to check two elements on each side of our middle element to find out where the array increases , where decreases, and where the peak is. And only then we can guarantee something about our max. Menos

↳

private static int recFindPeak(int[] a, int start, int end) { if(start == end) return a[start]; int mid = (start+end)/2; if((a[mid] > a[mid+1])&&(a[mid] > a[mid-1])) return a[mid]; else if(a[mid] > a[mid-1]) return recFindPeak(a, mid+1, end); else return recFindPeak(a, start, mid-1); } Menos

### Suppose we hire you, and you and the rest of the new interns decide to go buy a cup of coffee. Each intern purchases one cup of coffee. One of the interns suggests everyone play a game. Everyone will flip a fair coin, dividing the group of interns into two subgroups: those that got heads and those that got tails. The game is this: whichever group is smaller evenly splits the cost of everyone's cup of coffee (i.e. if there are 5 interns, 3 get H, 2 get T, then the two interns that got tails each buy 2.5 cups of coffee). However, nothing says you need to play this game. You can choose to buy your own cup of coffee and not play the game at all. The question: Should you play this game? (Note: You may assume that there is an odd number of interns, so there are no ties, and that if everyone gets H or everyone gets T, then everyone loses and just buys their own cup of coffee).

18 respuestas↳

Assume each coffee costs $1, for simplicity. So this is effectively a choice between two outcomes: paying $1 with probability 100%, or paying $0 with some probability and paying more than $0 with some probability. So you ask yourself: what is your expected cost in the second case? Give that a try and see if you can figure it out. However, I want to remind you that the question is "should you play this game?" The answer to this question isn't just a math question. If you only work out expected values, you've missed the point. For example, a separate question (with the same kind of flavor as the direction I'm trying to lead you) is this: suppose I give you a choice of two outcomes. Either you get $1 with 100% probability or I give you $500,000,000 with probability 1/100,000,000 and 0 otherwise. Which would you pick? Now what if it was the same first choice, but the second choice was $50 with prob 1/10 and 0 otherwise? Now which would you pick? These are the kinds of things you want to think about while answering this kind of question. Let me know if you have anymore questions. And if you want me to post the answer, just let me know. Menos

↳

The probability of winning isn't 50%. It's actually slightly above 50%, but that's not the way to look at it. The total number of coffees that need to be bought is n, where n is the number of interns. Going into this game, every intern is the same so they each have the same expected value, and the sum of the expected values must equal -n. So everyone has an EV of -1 as claimed. Menos

↳

I say yes. To play the game. Only because I'm prepared if I lost. The fact that I can afford to loose, makes me want to try my chance at wining Menos

### non disclosure agreement

18 respuestas↳

I don't actually know. I mean, that's what I would do if I were amazon, but I did not read anything about them webcamming me, and I also didn't happen to notice the webcam light being on. That didn't mean it didn't happen, though. Menos

↳

I took the test in c++. The function interfaces were in base c, though, so it would probably look more or less identical in c or java. Menos

↳

Hi, I just finished my second assessment test for Amazon and passed all their tests for the 2 coding questions. Was the second test really the final round? There isn't a final third round? Thanks! Menos

### What was one of your best achievements on a project in the past?

18 respuestas↳

From what i've heard and seen, just wait, following up will barely do you any good. Menos

↳

Hey, I just have one question out of curiosity, was the second online assessment web-cam proctored? Menos

↳

i heard amazon is changing their recruiting process. Many people complained that the online proctoring was an invasion of their privacy. I also had a second online assessment but it was not webcam proctored. I am assuming the recruiting process is now two online non webcam assessments then a final phone interview. My friend had that round of interviews with Amazon 2 weeks ago. Menos

### DS, Algorithms.

18 respuestas↳

Review Leetcode, CTCI.

↳

Hi, did you interview on Jan 27? Did the engineer ask about behavioral questions or resume questions or did they just jump right into the coding questions? Also I finished my second assessment a week ago but still didn't get a reply back. Was that normal for you? Menos

↳

Hi, did you interview on Jan 27? Did the engineer ask about behavioral questions or resume questions or did they just jump right into the coding questions? Also I finished my second assessment a week ago but still didn't get a reply back. Was that normal for you? Menos

### Fit questions: Why do you want to be a trader? Why should/shouldn't we hire you? Math: 1. Flip a fair coin 8 times. What's the probability that the number of heads is a multiple of 3? 2. You mentioned on your resume that your favorite author is David Foster Wallace. Estimate the number of copies of Infinite Jest that have been read cover to cover. 3. You have a 2x1x1 brick. Define the distance between two points on the brick to be the infimum of the lengths of all paths between them on the brick. What is the maximum possible distance between two points on the brick?

17 respuestas↳

The shortest path has length sqrt(6). sqrt(1^2 + 1^2) = sqrt(1 + 1) = sqrt(2) sqrt(2^2 + sqrt(2)^2) = sqrt(4 + 2) = sqrt(6) Menos

↳

If the farthest points are opposite corners, then wouldn't the shortest path be sqrt(10)? I'm not sure how you get 2*sqrt(2) Menos

↳

0 is a multiple of 3.

### Given a number n, find the largest number just smaller than n that can be formed using the same digits as n.

16 respuestas↳

My answer did not show properly: public static int smaller(int n){ if(n less than 10) return n; int d0 = n % 10, n2 = n / 10, d1 = n2 % 10; if(d1 greater than d0) return n / 100 * 100 + d0 * 10 + d1; return smaller(n2) * 10 + d0; } Menos

↳

It doesn't work, please ignore it This one works: public static int smaller(int n){ int i = 1; int result = 0; while(i ＜＝ n / 10 && n / i / 10 % 10＜= n / i % 10) i *= 10; if(i ＞ n / 10) return n; int d = n / i / 10 % 10; int j, x; for(j = 1; (x = n / j % 10) >= d; j *= 10) result = result * 10 + x; result += j * x; result = result * 10 + d; for(j *= 10; j ＜= i; j *= 10) result = result * 10 + n / j % 10; return result + n / i / 100 * i * 100; } Menos

↳

# Python implementation def getSmallerNumWithSameDigits(num): strNum = list(str(num)) endI = len(strNum)-1 endDigit = strNum[endI] # Walk backwards through digits for i in range(len(strNum) - 1, -1, -1): digit = strNum[i] # If the digit is greater than the end if digit > endDigit: # Swap them strNum[endI], strNum[i] = strNum[i], strNum[endI] break # Put back into int form return int(''.join(strNum)) print getSmallerNumWithSameDigits(912345678) Menos

### Find the second largest element in a Binary Search Tree

15 respuestas↳

The above answer is also wrong; Node findSceondLargest(Node root) { // If tree is null or is single node only, return null (no second largest) if (root==null || (root.left==null && root.right==null)) return null; Node parent = null, child = root; // find the right most child while (child.right!=null) { parent = child; child = child.right; } // if the right most child has no left child, then it's parent is second largest if (child.left==null) return parent; // otherwise, return left child's rightmost child as second largest child = child.left; while (child.right!=null) child = child.right; return child; } Menos

↳

find the right most element. If this is a right node with no children, return its parent. if this is not, return the largest element of its left child. Menos

↳

One addition is the situation where the tree has no right branch (root is largest). In this special case, it does not have a parent. So it's better to keep track of parent and current pointers, if different, the original method by the candidate works well, if the same (which means the root situation), find the largest of its left branch. Menos