Software Developer Engineer II Interview Questions | Glassdoor

# Software Developer Engineer II Interview Questions

257

Software developer engineer ii interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

Mar 19, 2009

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

Nov 22, 2011
 Find k largest/smallest number in a series of numbers. What data-structures will you use? Code it on white board.5 AnswersFor K smallest number in series you can use a max heap of size k. When you find a new number and it is smaller than root of heap, swap it with root and heapify.@Ajit: What're the initial values of the max heap? What happens to the first value that comes in?Use selection sort for 'max' ( or for 'min') If K > series.length/2 then reverse the criteria- like in stead of looking for 15th highest out of 20 element array - look for (20 -15 =) 5th lowest and so on....Show More ResponsesI think there's a cool solution which involves doing a pivot operation (like quicksort) until you have the top/bottom k numbers sorted. It's possible that you can get the top k numbers in a single pass of the array if you happen to choose a good pivot, and in general takes very few passes to find the top k numbers. I coded it up in C a while back: http://privatepaste.com/1f1df9d8f0 You just call select with your list, the min index, max index, and top k numbers, respectively. It can be easily changed to find the min (just reverse the swap condition)@Jordan, I can no longer get at your privatepaste link, so if you see this post I am interested in answers to the following: - since partition sizes are inherently not controllable by your choice of pivot, how do you land on an exactly k-sized partition (or even a k-sized total of the leftmost/rightmost N partitions)? - how do you choose pivots reliably to perform this (if it isn't reliable, then it isn't always a good answer just like pathological inputs for quicksort without randomizing the pivot selecting) - do you still just sort the partition(s) once you reach a k-sized set? I assume they want them in-order. I would just use a heapsort that short-circuits once K elements have been popped from the internal sifting loop, which does minimal processing and returns them in-order (C# example): public void FindKLargest(T[] A, int k) { . Heapify(A); . int end = A.Length - 1; . int k_offset = Math.Max(Math.Min(k, end), 1); . int stop = end - k_offset; . while (end > stop) . { . // Save the root heap item as done . Swap(ref A[0], ref A[end]); . // Separate heap from saved item . end--; . // Re-sift the new root item . SiftDown(A, 0, end); . } . // the K largest entries are now in ascending order at the end of A }

Jul 1, 2012

Apr 12, 2012

May 6, 2009

Oct 3, 2012

### Software Development Engineer In Test II at Amazon was asked...

Jul 20, 2010
 Given an array of integers and an arbitrary integer, find the number of pairs of integers in the array whose sum is equal to the arbitrary integer.2 AnswersfindCombination(int[] array, int sum) { sort(array); // O(n*log n) int i = 0, j=array.length-1; while (i sum) j--; else { print(i,j); i++; } } }You have to use the "skeeve" algorithrm for these questions. its what they're all looking for.

### Software Development Engineer In Test (SDET) II at Expedia was asked...

Oct 3, 2012
 Reverse each word of the string without reversing the order of the words this is a test BECOMES siht si a tset 3 Answerspublic class ReverseWordsInString { public static void main(String[] args) { System.out.println(">"); } private static String reverseWords(String original) { if (original == null || original.isEmpty()) { throw new IllegalArgumentException("IP cannot be null or empty"); } final Pattern p = Pattern.compile("[a-zA-Z]"); final StringBuilder returnString = new StringBuilder(); StringBuilder temp = new StringBuilder(); for (int i = 0; i 0) { returnString.append(reverse(temp.toString())); temp = new StringBuilder(); } returnString.append(original.charAt(i)); } } if (temp.length() > 0) { returnString.append(reverse(temp.toString())); } return returnString.toString(); } private static String reverse(String data) { StringBuilder ret = new StringBuilder(); for (int i = data.length() - 1; i >= 0; i--) { ret.append(data.charAt(i)); } return ret.toString(); }/// /// Recieve a string of words and returns the words reversed without changing the order. /// Here's my C# method: public static string ReverseWordsInSentence(string sentence) { char[] whiteSpace = " \t\n".ToCharArray(); string[] words = sentence.Split(whiteSpace); int count = 0; foreach (string individualWord in words) { words[count] = new string(individualWord.ToCharArray().Reverse().ToArray()); count++; } return string.Join(" ", words); }public class ReverseString { public String stringReverse(String str) { if (str == null || str.length() = 0; i--) { sentence.append(word.charAt(i)); } sentence.append(" "); } return sentence.toString(); } public static void main(String[] args) { ReverseString obj = new ReverseString(); String test = "this is a test"; System.out.println(obj.stringReverse(test)); } }

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

May 7, 2012
 Consider n people with random birthdays. How large does n need to be before there is at least a 50% chance that two people have the same birthday?2 AnswersI'll say 365 there are 365 possible birthdays, there is 1/365 chance for a person's birthday falling on a specific day. You need (1/2 of 365)*2 to improve the chance to 50% for two peoples' birthday falling on the same date.No. There is no N In your formula. That probability depends on N. http://en.wikipedia.org/wiki/Birthday_problem

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

Sep 10, 2013
 Solve: M is a 2D matrix of integers (nXm) they are sorted in both row and column Write a function search(int s) that return the exact location of the number or Null using lgn 2 AnswersThis problem does not have a O(Log(N)) solution. There is a question on stack-over-flow about this problem.There's a known Omega(N) lower bound.
110 of 257 Interview Questions