Intern Interview Questions | Glassdoor.ie

Intern Interview Questions

255

Intern interview questions shared by candidates

Top Interview Questions

Sort: RelevancePopular Date

Given an array of integers [1,2,3,4]. and target t = 5. Come up with a solution that will print out all the unique pairs in the array that are equal t.

3 Answers

Found this very hard, but the interviewer gave subtle hints, and I eventually came up with the idea of using a nested for loop. But I was not completely correct as I had set the inner incrementer to j = 0 instead of j = i+1 .

array a=new array(); foreach(int i in a) { if(i==t) { console.writeline(i.toString()); } } //c# code,i am not sure if this is what they whanted

public class CalculateTuple { /** * @param args */ public static void main(final String[] args) { final int arr[] = { 1, 2, 3, 4 }; final int sum = 5; solution(arr, sum, false); } /** * find possible tuple for provided sum * * @param input * input array * @param expectedSum * expected sum value for the tuple * @param isCommutative * true : (1,2) != (2,1) will give you both tuple <br> * false : (1,2) == (2,1) are same and give you only (1,2) */ public static void solution(final int input[], final int expectedSum, final boolean isCommutative) { final Map indexedArray = new HashMap(); final Map uniquePair = new HashMap(); final int length = input.length; for (int i = 0; i &lt; length; i++) { indexedArray.put(input[i], i); } int count = 0; for (int i = 0; i &lt; length; i++) { final Integer integer = indexedArray.get(expectedSum - input[i]); if (integer != null &amp;&amp; integer != i) { if (isCommutative || (null == uniquePair.get("(" + i + "," + integer + ")") &amp;&amp; null == uniquePair.get("(" + integer + "," + i + ")"))) { System.out.println("(" + i + "," + integer + ")"); uniquePair.put("(" + i + "," + integer + ")", "(" + i + "," + integer + ")"); count++; } } } System.out.println("Found " + count); } }

A king wants to hold a party, for which he has 8 kegs of wine, one of which he knows is poisoned. If someone consumes any of the poisoned wine, he will drop dead in exactly one months time. The king has 3 servants who have volunteered their lives to test the kegs of wine. What is the shortest amount of time in which the king can identify which keg of wine is poisoned and dispose of it so he can hold the party.

4 Answers

What is dhcp

2 Answers

Compute all the intersections of two sets of segments in a line.

2 Answers

Given a set of cities, each with a given population, select randomly a city with a probability that is proportional to the population.

2 Answers

Ambitions

1 Answer

What makes a good fit for our internship?

1 Answer

What is machine learning techniques do I know?

1 Answer

Tell me about yourself and talk me through your CV. I just explained my current degree and then led on to past degree and recent employment.

1 Answer

difficult time working with someone

1 Answer
110 of 255 Interview Questions