Engineer ii Interview Questions | Glassdoor.co.in

# Engineer ii Interview Questions

755

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.

30 Apr 2013

26 Jul 2017

### 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[5]; int[] b = new int[5]; int[] c = new int[5]; int sum= 0; a[0]=2;a[1]=8;a[2]=9;a[3]=7;a[4]=10; b[0]=3;b[1]=2;b[2]=10;b[3]=9;b[4]=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); } }

22 Jul 2017

### 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?

### UI Engineer II at Flipkart was asked...

26 Apr 2017
 Q: How do you flat an Array?3 Answersvar flattenArray = [].prototype.concate.apply([], UnflattenArray) OR function flatten(arr) { return arr.reduce(function (flat, toFlatten) { return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten); }, []); }[[1],[[2],[3]]].reduce((acc, curr) => { return acc.concat(Array.prototype.concat.apply([],curr)); }, [])// Method 1 const flattenArr = (arr) => { if(arr instanceof Array && arr.length === 0) return []; else if(!(arr instanceof Array)) return [arr]; return flattenArr(arr[0]).concat(flattenArr(arr.slice(1))); } // Method 2 const flattenArr = (arr) => { const result = []; const helper = (arr) => { if(Number.isInteger(arr)) { result.push(arr); } else if (Array.isArray(arr)) { for(let i = 0; i < arr.length; i++) { helper(arr[i]); } } } helper(arr); return result; }

### 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[255]; 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 OneAssist Consumer Solutions was asked...

28 Feb 2019
 rainwater collection problem2 Answerssolved and written code using 2 arrays containing the left and right side maximas for each elementOneassist is cheater company. They could not support to his customer. His policy is very bad. I can not believe that Organization is very cheater quality policy.

### 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
110 of 755 Interview Questions