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

Software Development Engineer II Interview Questions

177

Software development engineer ii interview questions shared by candidates

Top Interview Questions

Sort: RelevancePopular Date

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

6 Answers

Sort 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 for

package 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; } }

One or more comments have been removed.
Please see our Community Guidelines or Terms of Service for more information.

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 Answers

Trees, DP, Arrays

3 Answers

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 Answers

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 Answers

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 Answers

given a very large file (Billion lines in Tera Bytes) and you have only few GB of memory, what is your approach to search a word in the entire file and print the line number in efficient way.

2 Answers

I was asked two questions. One was given an array of integers find triplets such that a^2 + b^2 = c^2.

2 Answers

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 Answers

How would you design a chat application (Backend)

1 Answer