Intern Interview Questions | Glassdoor.ie

# Intern Interview Questions

289

intern interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

11 Feb 2014

### Software Development Engineer I Intern at Amazon was asked...

3 Oct 2015
 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 AnswersFound 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 whantedpublic 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
* 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 < length; i++) { indexedArray.put(input[i], i); } int count = 0; for (int i = 0; i < length; i++) { final Integer integer = indexedArray.get(expectedSum - input[i]); if (integer != null && integer != i) { if (isCommutative || (null == uniquePair.get("(" + i + "," + integer + ")") && null == uniquePair.get("(" + integer + "," + i + ")"))) { System.out.println("(" + i + "," + integer + ")"); uniquePair.put("(" + i + "," + integer + ")", "(" + i + "," + integer + ")"); count++; } } } System.out.println("Found " + count); } }

11 Jan 2012
 The expectation of a dice roll.2 Answers(1+2+3+4+5+6)* 1/6Expected value of a single dice is 3.5

9 Feb 2011
 Compute all the intersections of two sets of segments in a line.2 AnswersOnly implemented the naive solution O(M x N) time, should have implemented a line sweeping algorithm.int line1[line size] int line2[line size] int overlap[line size] for each segment in set1 for i = segment start to segment end line1[i]++ for each segment in set2 for i = segment start to segment end line2[i]++ for i = 1 to line size if line1[i] and line2[i] overlap[i] = 1

### Intern at VMware was asked...

8 Aug 2016
 What is dhcp2 AnswersRight answerDHCP stands for dynamic host config protocol. Basically, it is a protocol in which a device is provided an IP address (and other necessary information) when connecting to a network. It is useful because in a network, a device must have a unique IP address, and DHCP allows us to reuse addresses, freeing other addresses for more devices.

8 Mar 2012
 If a shooting star has an 80% chance of appearing in the next hour, what is the chance of it appearing in the next half hour?1 Answer20% chance not appearing in the next hour 44.7% chance not appearing in the next half hour (44.7% * 44.7% = 0.2) so it's 55.3 chance appearing in the next half hour

9 Feb 2011
 Given a set of cities, each with a given population, select randomly a city with a probability that is proportional to the population.2 AnswersGave a naive O(1) time O(population) space solution, then created a python generator that implemented what is requested in O(n_cities) worst-case time.int size = 0 int city_range[] initialization for each city i city_range[i] = size size += population[i] selection generate random integer r ranging from 0 to size for i = 0 to n_cities if city_range[i] <= r and r < city_range[i] + population[i] return city i

### Intern at Spector Information Security was asked...

20 May 2017
 What career do I want to follow (networking, administration, etc)?1 AnswerI did not have an answer for this question, but I told them that I am open to learn as much as I can.