Developer Intern Interview Questions | Glassdoor

# Developer Intern Interview Questions

760

Developer intern interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

### Software Developer Intern at Halliburton was asked...

Nov 2, 2009
 What is the angle between the two arms of the clock at 2:40?7 Answersint time(int h, int m) { angleH = (h*360)/12; angleM = (m*360)/60; return Math.abs(angleH - angleM); }160 degreesif a circle is bisected, the degree would be 180, as a circle is 360 degrees. How do you come up with 160?Show More Responses160 of coursehttp://en.wikipedia.org/wiki/Clock_angle_problem#Equation_for_the_angle_between_the_handsThis should help http://www.mathcelebrity.com/clockangle.php?num=2%3A40&pl=Calculate360*(40/60)-360*(2/12)-(360/12)*(40/60)=160

### Software Developer Intern at Google was asked...

Jan 5, 2011
 Write a program to find (x^y) % z5 Answersresult = x mod z for i = 2 to y do result = (result * x) mod zI think there is some point we need to check. first will x be negative? If so, we need to handle this problem In addition, in the case y is very large, a O(y) algorithm is not a good idea, we might need to use the O(lg Y) one.(x ^ y) % z is equal to: (x << (y-1)) % zShow More ResponsesI guess the point is how to avoid overflow. Good algorithms for this does not lead to overflow and return the correct answer; normal ones may easily lead to overflow.I guess we need to use Congruences from Number theory here

### Amazon Software Developer Intern at Amazon was asked...

Apr 1, 2011
 how would you design how a cellphone implements its contact list when you press a certain letter. For example, If you press M it will tell you all the names starting with M. then if you press MI it will tell you all names starting from MI and so forth....6 AnswersUse a tree structure where each level is a consecutive character. So, if M is chosen first, travel down the "M" branch. To show remaining set of possible contacts, traverse the tree and print out all leaf nodes.Use a trie or radix (patricia) treeKeep a sorted contact list in an array. The names will be in char arrays so the access time is constant for a specific index. Do a binary search for the left boundary (the first appearance of a match and the right boundary (the last appearance of a match). Iterate through that index range. When dealing with mobile space might be an issue and making such a tree might cost more overhead then just looking through a sorted array.Show More ResponsesThe tree answer is a probably the right idea, but what about edge cases like if you have a contact Matt and a contact Matthew, in this case Matt will not be a leaf node but be an intermediary node on the way to Matthew. Any clarification would be appreciatedyou'll probably need a suffix tree for this oneWhat about having a hash map where the keys are the various letter of the alphabet, and the associated values are sorted collections of names starting with that same letter as the corresponding key.

### Financial Software Developer Intern at Bloomberg L.P. was asked...

Mar 13, 2013
 Linked list memory management: deleting a node from the middle of a list was easy. Next question - how to delete a node from the end of a list. Was too tired to think and realize this was a trick question.5 AnswersYou can't, since the pointer already points to null. No way around it.Disagree, Instead of 1 use 2 pointers, having pointer 1 one step ahead of pointer 2, once pointer 1 points to NULL, use pointer 2 to remove the last node.It depends. on how the link-list is implemented.Show More Responsescheck node->next->next equals to null or not, then can just update node->next = nullI guess this question makes sense only when we don't know the Head node !

### Software Development Intern at Epic Systems Corporation (Wisconsin) was asked...

Jun 7, 2012
 Possible anagrams of a string ... 4 AnswersThey were asking how to write a program to find anagrams of a string?They were asking how to write a program to find anagrams of a string?Yes, they did ask me to write the programShow More ResponsesThe question I got at least was not just a straight anagram one but there were some constraints imposed on it

### Software Development Engineering Intern at Amazon was asked...

Jun 10, 2012
 Can you think of an example of a scenario where you would want to use a tree with more degrees of branching than a binary tree?4 AnswersIf you need to represent a company's personal structure. For example, one president is trailed by more than just two vice presidents and it will span....Great example for this: modeling a dictionary of possible words. I.e. a->g->r works because aggregate but a->g->(g) wouldn't because the second g wouldn't exist in the tree (no words begin or are formed with the string "agg"). I've actually received this in an Amazon interview where I was asked to model the game Boggle.B-TreeShow More ResponsesDatabase indexes is a classic example

### Software Development Engineer Intern at Microsoft was asked...

Jul 6, 2012
 string compression: aaabbbbcc ->a3b4c25 AnswersJava code: private static String compressString(String input) { StringBuilder result = new StringBuilder(); char currentCharacter; int count; for(int i = 0; i < input.length(); i++) { currentCharacter = input.charAt(i); count = 1; while(i < input.length() - 1 && input.charAt(i + 1) == currentCharacter) { count++; i++; } result.append(currentCharacter); result.append(count); } return result.toString(); }//C++ using namepsace std; main(int argc, char** argv) { string input = "aaaabbccccddd"; string output; char lastchar = input[0]; int count = 0; for (int i = 0; i < input.size(); i++) { if (input[i] != lastchar || i == input.size() -1 ) { output += lastchar; output += count; count = 0; lastchar = input[i]; } count++; } }What is a character is repeated more than 10 times? aaa..14times..bbb.cc.. a14b3c3 - how do we decode it then? if we assume input string can contain only alphabets- then its fine.Show More ResponsesMake an array of size 256 for all ASCII characters. Iterate through string and increment each character that matches the array. Iterate through ASCII array and concatenate letters and element valuesI'd probably just use a hash map (in-order map just like C++'s map) and iterate through the string counting the number of occurrences of each character. Then, using the in-order property of the hash table, the string could then be printed out in the aforementioned format: aaabbbbcc ->a3b4c2.

### Financial Software Developer Intern at Bloomberg L.P. was asked...

Mar 5, 2010
 Suppose there is a rectangular map where you can only travel up or right to go from a start location in the bottom left corner to the top right corner, and each move is discrete. Write a program that prints all possible solutions to get from the start to finish.4 AnswersSuppose you need 5 R (right moves) and 5 T (top moves) to reach the upper right corner. Then you can do a permutation of the string, "RRRRRTTTTT" to get all the possible paths.@Sid Ray: Thanks for the hint.Thx for a nice hint.Show More Responses#include using namespace std; const int maxx = 5; const int maxy = 5; void printpath(int x = 1, int y = 1, string path = "") { if(x

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

Feb 10, 2013
 I was asked two questions. Q 1. You are given two version numbers of a software, like Version 10.3.4 and Version 10.3.41. Write a program to find out which of the version numbers are the latest. If version 1 is latest output -1, if version number 2 is latest output +1 else output 0 if same version. Both the version numbers are taken as string. He also asks to make the program of minimum time complexity as we can. At the end he also asked the difference between an iterative program and one with recurrence and their advantages and disadvantages. Q 2. Given two files with a list of application IDs (or some kind of data) stored in them , write a program to compare the data in the two files and output all the common data found in each. What data structure would you use and why ? Give a minimum time and space complexity algorithm. Why did you choose the particular data Structure or algorithm ?5 Answers1. This was a little tricky. You have to check for the decimal place in both the versions and then Store that part of the string till the decimal place in a temporary variable and then convert them to integer and check which one is greater. You have to keep on doing that till you reach the end of the version numbers or till when you find the answer 2. In the second question you can use Linked lists and then Binary Search Algorithm. The interviewer will ask you the reason for this.Why not just delimit the string with "." Then you'll have an array of string numbers. Then loop with the array from 0 -> n (depending on how many decimals there was) and compare. Return when one is greater than the other. You will have to check if you get a index out of bounds if one has more decimals than the other. Over all, that should be in n time.As for #2. HashTable it. Also n time.Show More ResponsesIf you are using c++, can't you just use the "compare" method that is built into the string class?Maybe not the best solution... the time complexity is O(n). public static void main(String[] args) { String ver1 = "10.22.7.3"; String ver2 = "10.22.8.4.1"; String split1[] = ver1.split("\\."); String split2[] = ver2.split("\\."); int max = split1.length > split2.length ? split1.length : split2.length; for (int i = 0; i i) { System.out.println(+1); break; } else if (split2.length i) { System.out.println(-1); break; } else { if (Integer.parseInt(split1[i]) > Integer.parseInt(split2[i])) { System.out.println(-1); break; } else if (Integer.parseInt(split1[i]) < Integer .parseInt(split2[i])) { System.out.println(+1); break; } } } }

### Software Development Intern at Palantir Technologies was asked...

Jan 24, 2012
 Given a bag of nuts and a bag of bolts, each having a different size within a bag but exactly one match in the other bag, give a fast algorithm to find all matches.4 AnswersSort both the sets. So the nut at ith position would map to the bolt at the ith position.This questions usually comes with the additional constraint that you cannot compare two nuts to each other or two bolts to each other. This would make sorting them separately impossible.We can hash the nuts with its size as a key, and look it up iterating through bolt array. This would take up o(n) time to hash and o(n) to lookup, which is o(n) total time.Show More ResponsesChandra, you couldn't simply hash the size. You would have do a quicksort-esque solution, where you randomly pick a bolt and find it's matching nut, and then use that as a partition(if it is not a good partion, meaning within n/4 to 3n/4 in size, simply throw it away and repartion, it is expected that this would take about 2 times on average to fulfill this requirement for a "good partition"). Then simply recurse on both partitions, leading to an O(n logn) solution. (If you don't see why, just draw out the recurrence tree).
1120 of 760 Interview Questions

More