Software Development Engineer II Interview Questions | Glassdoor.co.in

Software Development Engineer II Interview Questions

164

Software development engineer ii interview questions shared by candidates

Top Interview Questions

Sort: RelevancePopular Date

Software Development Engineer II at Microsoft was asked...

30 Apr 2013
 You are given an array of numbers. You need to print the length of the maximum continuous sequence that you encounter. For example if input is [3,8,10,1,9,6,5,7,2 ], the continuous sequences are{1,2,3} and {5,6,7,8,9,10} the latter is the longest one so the answer becomes 6. O(n) solution was asked for, assuming you have a hash map which supports O(1) insertion and fetching operations6 AnswersSort the given array and remove the duplicates if any. Initialization- longest =1; temp=1; Iterate through the array and find the difference between the two adjacent array elements. { If (diff==1) temp++; else { if(temp>longest) longest=temp temp=1 } } The value of longest variable is the longest sequence.Sorting makes the time complexity as O(nlogn). An O(n) solution was asked forpackage array; import java.util.Hashtable; /* * You are given an array of numbers. * You need to print the length of the maximum continuous sequence that you encounter. * For example if input is [3,8,10,1,9,6,5,7,2 ], * the continuous sequences are{1,2,3} and {5,6,7,8,9,10} * the latter is the longest one so the answer becomes 6. * O(n) solution was asked for, * assuming you have a hash map which supports O(1) insertion and fetching operations * src: http://www.glassdoor.com/Interview/Microsoft-India-Interview-Questions-EI_IE1651.0,9_IL.10,15_IN115_IP6.htm */ public class FindLengthOfLongestRandomlyDistContinousSequenceOfNumber { public static void main(String[] str){ int a[] = {3,6,8,1,5,7,0,9,2,4,10,14,13,12,11}; System.out.println(findLength(a)); int b[] = {5,2,3,1,6,7,10,8}; System.out.println(findLength(b)); } private static int findLength(int[] a) { int result = 0; Hashtable h = new Hashtable(); for(int i=0; i result){ result = curr.maxValue; } if(next != null){ next = h.get( curr.max); next.maxValue = curr.maxValue; h.put(a[i]+1, next); next.min = curr.min; } if(prev != null){ prev = h.get(curr.min); prev.maxValue = curr.maxValue; h.put(a[i]-1, prev); prev.max = curr.max; } h.put(a[i], curr); } } return result; } } class Node{ int maxValue; int max; int min; public Node(int v, int m, int n){ maxValue = v; max = m; min = n; } }Show more responsesstatic int findlongconsecutivesubseq(int[] arr) { HashSet s= new HashSet(); int ans=0; //put all entries in hashset for(int i=0;i ans) ans=j-arr[i]; } } return ans; }static int findlongconsecutivesubseq(int[] arr) { HashSet s= new HashSet(); int ans=0; //put all entries in hashset for(int i=0;i ans) ans=j-arr[i]; } } return ans; }http://www.geeksforgeeks.org/longest-consecutive-subsequence/

Software Development Engineer II at Amazon was asked...

4 Oct 2012
 Two sorted arrays. you can start from any one them, and then at common element you may or may not jump to other array. Continue in this manner till you reach the end of an array. Find the path that results the maximum sum.3 AnswersGreedy algorithm O(m+n); not really hard once you know it's greedy.DP can also be used... O(m+n) again...import java.util.*; class gAlg{ public static void main(String[] args){ int[] a = new int; int[] b = new int; int[] c = new int; int sum= 0; a=2;a=8;a=9;a=7;a=10; b=3;b=2;b=10;b=9;b=9; System.out.println(Arrays.toString(a)); System.out.println(Arrays.toString(b)); int i; for(i=0;i<5;i++){ c[i]=Math.max(a[i],b[i]); sum = sum+c[i]; } System.out.println(Arrays.toString(c)); System.out.println(sum); } }

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

5 Jun 2013
 Remove all characters of a string from another string. The algorithm should be less than O(m*n) where m & n are lengths of strings and the space used should be less than O(m+n).3 AnswersI have written a program using Hashmap and StringBuilder.An efficient solution to the problem can done using simple pattern matching. A sample solution goes as follows : public class SampleMain { /** * @param args */ public static void main(String[] args) { String charStream = "ABABCBABABABABABATGBHacbfoabcbahasacbJKOPLMNBGDESRABADACAJALAMNBADDHEMSZPQ"; String noise = "ABCPQR"; System.out.println("CharStream : " + charStream + "\n" + "Noise : " + noise + "\n" + "FliteredCharStream : " + func(charStream, noise)); } private static String func(String charStream, String noise) { String regex = "[" + noise.toLowerCase() + noise.toUpperCase() + "]"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(charStream); return m.replaceAll(""); } }import java.util.Arrays; public class Solution{ public static void main(String[] args){ System.out.println(remove("as","asasfsg")); } public static String remove(String s1, String s2){ boolean[] flags = new boolean; char[] a1 = s1.toCharArray(); char[] a2 = s2.toCharArray(); String str = ""; Arrays.fill(flags,false); for(int i=0; i=a1.length && i

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

10 Jun 2012
 Write algorithm for c compiler. 1 Answeralgorithm for C- Compiler 1.start . 2.include header files from the library (required for future compiling code) 3.In main create and allocate memory asked for. 4.Go through the conditions and use appropriate queries to have ALU working. 5.go for the end,if not generate error. 6.Stop.

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

22 Oct 2009
 How would you design a hotel reservation system?1 AnswerThis was a boring question. I gave a standard approach - doing a OO analysis to find the objects and go for layered model if there are scalability and integration requirements.

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

20 Jun 2013
 Bulbs problem1 AnswerSwitch on first switch for 5 minutes. light gets heated. After 5 minutes, switch off that light. Now switch on second, switch off third. Once you enter room, you can identify bulb with light is mapped to second switch. if you touch other two bulbs, you can identify the heated bulb is mapped to first switch.

Software Development Engineer II at Microsoft was asked...

4 Aug 2012
 What is one thing that you will develop if given a chance to work for facebook?1 AnswerI will add the nearest tourist spot who post their homedown and current city. This is use to know about their taste of thinking. And we will collect the advertisement who do business from that place.

Software Development Engineer II at Amazon was asked...

13 Jun 2011
 Design movie ticket booking system (for multiplex theater) with ER diagram. Also give some future extensions1 AnswerConsider movie, show time, seat availability, ticket price (different for different seat types)

Software Development Engineer II at Amazon was asked...

13 Jun 2011
 Write algorithm/code to find longest path between any two cities. 4X4 matrix was given. If there is no connectivity between two cities then the distance between them was given as -1. Its cyclic graph.2 Answershttp://stackoverflow.com/questions/4252215/optimizations-for-longest-path-problem-in-cyclic-graphFinding longest path between two nodes in a graph is an NP Hard problem. So, we should not try to find a polynomial solution to this problem. As you can see the given problem is of very small size. So even brute force is acceptable. Solution: Let there be n cities. GIven starting city as S and destination city as D. We are left with n-2 cities. There are approximately 2^(n-2) * (n-2)! ways for reaching D from S. Find length of all these ways and choose the smallest one.

Software Development Engineer II at Amazon was asked...

13 Jun 2011
 Write an algorithm to find the minimum-depth of a binary tree.1 Answerint minOfTwo (int nb1, int nb2) { return ((!nb1 && !nb2) ? nb1 : ((nb1 leftSubTree), minDepth(nptr->rightSubTree)); }
110 of 164 Interview Questions