Software Engineer II Interview Questions | Glassdoor.co.in

# Software Engineer II Interview Questions

444

Software engineer ii interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

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

19 Jun 2012
 Given an large list of unsorted numbers, find the smallest number. You can access the list only 3 numbers at a time, and keep moving forward 1 number at a time.6 AnswersOtherwise called the sliding window problemUse the selection sort and after the pass stop the iterating. Time complexity will be O(N) & only one swap.Use the selection sort and after the first pass stop the iterating. Time complexity will be O(N) & only one swap.Show more responsesDid they asked to write the code of the solution? or just pseudo code.And did they added any constraints? Otherwise this is pretty straight forward problem using Insertion sort.You can access the list only 3 numbers at a time: It tells we can read three numbers one after other in N/3 Iterations. So Time complexity will be O(N/3)This is sliding window problem and priority queue DS can be used to solve this.

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

19 Jun 2012
 Find the kth smallest number in an unsorted array with minimum complexity.2 AnswersUse partitioning so that sorting is not required.we can use max heap of size k. for more info http://www.careercup.com/question?id=14118753

### Software Engineer-II at Johnson Controls was asked...

7 Mar 2019
 Asked about the Asynch method of jquery?1 AnswerI told to use Ajax call with parameters. But may be they expected lot more, i can understand.

### 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 Engineer II White Box Testing In Java at Adobe was asked...

6 Sep 2014
 How can you sort a text file of 4Gb size in a computer system of 2 Gb ram.1 AnswerThey wanted to Know my approach of the solution but not the full solution. I answered with an example of Divide and Conquer DS concept. Interviewer was happy.

6 Sep 2014