10K

Intern Engineer interview questions shared by candidates

Top Interview Questions

Sort: Relevance|Popular|Date
Software Engineer Intern was asked...28 July 2009

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?

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. Less

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 Less

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 Less

non disclosure agreement

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. Less

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. Less

Yeah, it was for me. There was few days pause between the 2nd round and the offer, so maybe they looked at other parts of my resume and decided to forgo a 3rd round for me. So I really can't say for sure that you won't have more rounds. Less

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

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

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

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. Less

DS, Algorithms.

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? Less

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? Less

Given two strings representing integer numbers ("123" , "30") return a string representing the sum of the two numbers ("153")

public static String sumStrings(String a, String b){ char[] num1 = a.toCharArray(); char[] num2 = b.toCharArray(); int i = num1.length - 1; int j = num2.length - 1; StringBuilder sumString = new StringBuilder(); int carry = 0; while(i &gt;= 0 || j &gt;= 0){ int d1 = 0; int d2 = 0; if (i &gt;= 0) d1 = num1[i--] - '0'; if (j &gt;= 0) d2 = num2[j--] - '0'; int sum = d1 + d2 + carry; if (sum &gt;= 10){ carry = sum / 10; sum = sum % 10; }else carry = 0; sumString.insert(0, sum); } return sumString.toString(); } Less

The interviewer wanted a loop through the digits starting form right to left, adding them one by one, and keeping track of the carriage. Less

import java.util.Arrays; import java.util.Scanner; public class AddNumericStrings { public static void main(String[] args) { final Scanner in = new Scanner(System.in); while (true) { System.out.println("Enter 2 numeric strings : "); String x = in.nextLine(); String y = in.nextLine(); System.out.println(add(x.toCharArray(), y.toCharArray())); } } private static char[] add(char[] big, char[] small) { char[] result = new char[big.length + 1]; Arrays.fill(result, '0'); for (int i = big.length - 1, j = small.length - 1; i &gt;= 0 || j &gt;= 0; i--, j--) { char x = big[i]; char y = '0'; if (j &gt;= 0) { y = small[j]; } int val = x - '0'; val += (y - '0'); result[i+1] += val % 10; if (val &gt; 10) { result[i] += (val/10); } } return result; } } Less

Suppose we can translate numbers into characters: 1-&gt;a, 2-&gt;b, ...26-&gt;z given an integer, for example, 11223, output every translation of the number.

Well I think the first answer in totally wrong except the first one, Here is what I have: aabbc kvc alw kbw aavc aabw kbbc albc Less

In Java, a recursive solution is: public static void main(String[] args) { String s = "11223"; char[] N = s.toCharArray(); char[] S = new char[N.length]; m(0,0,N,S); } public static void m(int i, int j, char N[], char[] S){ if (i==N.length){ System.out.println(new String(S, 0, j) ); return; } S[j]=(char)('a'+Integer.parseInt(""+N[i])-1); m(i+1, j+1, N, S); if (N[i]=='1' || (N[i]=='2' &amp;&amp; N[i+1]&lt;'7')) { S[j]=(char)('a'+Integer.parseInt(""+N[i]+N[i+1])-1); m(i+2, j+1, N, S); } } Less

no body use dp?

To find and return the common node of two linked lists merged into a 'Y' shape.

For a Y shaped like this: 1 -&gt; 2 -&gt; 3 -&gt; 4 -&gt;7 -&gt; 8 -&gt; 9 5 -&gt; 6 -&gt; 7 -&gt; 8 -&gt; 9 where the trunk portion is of constant length, it is easy. Get the length of the first list. In our case 7. Get the length of the second list: 5. Difference is 2. This has to come from the legs. So, walk the difference in the larger list. Now node1 points to 3. node 2 points to 5. Now, walk through the two lists until the next pointers are the same. Less

@kvr what if the lists are 1-2-3-4-7-8-9 and 12-13-14-5-6-8-9

i think that kvr's answer is the best. @snv if the two lists are linked by the very last two nodes, then you would find out after you are checking the values of the second two last two nodes. you just got unlucky and basically have to check until the very end. so basically, as a diagram with your example, it would look like this 1 -2 -3 -4-7-8-9 x -x -x -x -x-o 12-13-14-5-6-8-9 (sorry about spacing) but because you know the difference in length is 0, you can start comparing the two lists of nodes one by one. from the very beginning. Less

Determine if an array from 1..n has a duplicate in constant time and space.

If an array has elements from 1 to n the size of the array will be n, thus if the size of the array is greater than n, there must exist a duplicate. Less

What are the properties of an array that affect time complexity? Usually we're talking about the size of the array, N, such that linear time operations, O(N), are those that perform an operation on each of the elements in the array. However, an important thing to consider is that you can evaluate N (the size of the array) itself in constant time. The only way this can be done in constant time is if the input satisfies the precondition that "1..n" means there are no *missing* values in that range. In other words, such an array from "1..5" must contain at least one instance of the numbers 1, 2, 3, 4, and 5. With that precondition, you know that the length of the array will be 5 if no duplicates and greater than 5 if it does contain duplicates. Less

SUM(array) - (N(N+1)/2) = missing number.

If you have a refrigerator in an isolated room (no heat in or out) and left the door to the refrigerator open, what would happen to the temperature to the room? Would it go up, down or say the same?

The refrigerator will warm up the room. If you look on the back of the refrigerator, you will see metal grating. Touch it. Its warm! A refrigerator is transporting heat from the inside cavity to the outside. However, the power cord running from the wall is pumping energy into the refrigerator/room. Energy is powering the refrigerator. It is also running an irreversible process, the energy dissipates out as heat and work (mostly heat), making the net temperature of the room increase. Less

In this case, there is a net gain of energy from the refrigerator outlet into the room and no loss of energy out of the room. Thus, the room will warm up since there is a gain of energy. Less

The temperature and overall heat content of the room will increase. Yes, the fridge it providing cooling, but it is doing this by removing heat from part of the air and dumping it into other parts of the air, all while doing work which is harnessed from the power input (electricity) from the wall. In other words, the heat in the air is just displaced from one area of air to another, so no loss nor gain of net heat, HOWEVER the work used to do this creates additional heat. If you consider this from a total energy standpoint, all energy within the room is fixed, except there's energy being added through the power input, so there's an increase in energy with time. I'm shocked at some of the other answers here, I hope those saying the temperature remains the same do not have mechanical engineering degrees. Less