Software development engineer ii Interview Questions in India | Glassdoor.co.in

# Software development engineer ii Interview Questions in India

358

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; } One or more comments have been removed. Please see our Community Guidelines or Terms of Service for more information.

### 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-II at Amazon was asked...

19 Mar 2019
 Trees, DP, Arrays3 AnswersIt's literally waste of time. It's been more than a month I gave interview, and no response from the HR team.Especially this mahadevpura office HR team. I and two of my friends gave interview and passed all rounds. After two weeks of gap sent me an email saying you'll have to give chime call. In that two weeks gap I have mailed 3-4 times asking about the status, no response from the HR team. So I completed my chime call interview as well and it went pretty well. It's been more than a month no updates from the HR team. Same as before sent them couple of emails , no response.What questions were asked in chime call?

### 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 II at Microsoft was asked...

27 Oct 2012
 I was asked two questions. One was given an array of integers find triplets such that a^2 + b^2 = c^2.2 AnswersOne way to do this could be ____________________________________________________ #include #include "math.h" using namespace std; int arr[] = {1,0,4,5,3,2,1,8,0,7}; void test(int a, int b, int c) { if( a*a + b*b == c*c) { cout << "Found a triplet: (" << a << "," << b << "," << c << ")" << endl; } } int main() { int size = sizeof(arr) / sizeof(int); if(size < 3) return -1; for(int a=0; aHere is a O(n) solution int[] nums = new int[] { 3, 5, 6, 2, 4, 16, 61,8,10,7}; int[] lengths = new int[nums.Max() + 1]; for (int i = 0; i > pythaTriplets = new List> (); for (int i = 2; i ( 2*i,i*i-1,i*i+1)); } } catch { continue;} } pythaTriplets.Dump(); //2x, x*x-1, x*x+1

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

14 Sep 2018
 They gave me an open ended problem , optimizing some part of their operations. Given a map and multiple locations from where an order has to be procured , Delivery executive location and customer location, how would you find the best path.2 AnswersIts an open ended problem so no perfect solution but they want to see your thinking process. You can use small optimizations and break the problems into parts. Solve each part as best you canHow did you modelled the problem ? Which data strcutures did you used for this problem ?

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

11 Oct 2014
 Given an integer, find the next biggest integer whose digits are in increasing order. Example: Input: 118 Output: 123 Input: 127 Output: 234 Input: 987 Output: 1234 Desing question: Design a parking space to park a car.2 AnswersBelow is the Function for solving the same : int numberOfDigitInK(int k) { int count = 0; while (k % 10 != 0) { k = k / 10; count++; } return count; } int findNextHigherDigit(int k) { int count = this.numberOfDigitInK(k); int higherNumber = 0; int firstDigit = k / (int) Math.pow(10, count - 1); int flag = count; int incrementer = 0; int lastResort = 0; int one = 1; while (flag + 1 > 0) { lastResort += one * Math.pow(10, flag); flag--; one++; } flag = count; while (flag > 0) { higherNumber += firstDigit * Math.pow(10, flag - 1); flag--; firstDigit++; incrementer += 1 * Math.pow(10, flag); } while (higherNumber k) { return higherNumber; } higherNumber += incrementer; } return lastResort; } return lastResort; }Correct code : int numberOfDigitInK(int k) { int digits = 1 + (int)Math.floor(Math.log10(k)); return digits; } int findNextHigherDigit(int k) { int count = this.numberOfDigitInK(k); int higherNumber = 0; int firstDigit = k / (int) Math.pow(10, count - 1); int flag = count; int incrementer = 0; int lastResort = 0; int one = 1; while (flag + 1 > 0) { lastResort += one * Math.pow(10, flag); flag--; one++; } flag = count; while (flag > 0) { higherNumber += firstDigit * Math.pow(10, flag - 1); flag--; firstDigit++; incrementer += 1 * Math.pow(10, flag); } while (higherNumber k) { return higherNumber; } higherNumber += incrementer; } return lastResort; }

### Software Development Engineer-II at PayPal was asked...

4 Nov 2017
 1. Print unique words sorted in order of length from a file. 2. Rotate an array 3. How threads work? How threads work in a single processor system? 2 Answers1. I gave an HashMap> solution. But the interviewer expected a TreeMap solution. But a TreeMap would not be suitable for this question since it will not add elements of same length. 2. I gave him a O(n*d) solution with constant space. He wanted an O(n) with constant space solution which I could not give.We can use treemap along with comparator to sort based on words length.

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

11 Jan 2020
 Round 1: DS & Algo 1. Serialize and Deserialse Tree 2. Rat Maze problem (Backtracking) Round 2: Design Design Redis (LRU policy), Design should take care of multi-threading Round 3: Design Design Distribute Global Lock Round 4: Technical Manager - about work - Design a analytics platform that collect logs from multiple systems and provide insight from that 1 AnswerThere's a lot of elements to typically cover in these questions, clarifications, scoping, making sure you're answering the actual question the interviewer is looking for you to answer, etc. Could be worth doing a mock interview with one of the Prepfully Microsoft Software Development Engineer II experts... they've worked in the role so they clearly know how to get through the interview. prepfully.com/practice-interviews

25 Feb 2021