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

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

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

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

Write algorithm for c compiler.

1 Answer

How would you design a hotel reservation system?

1 Answer

Bulbs problem

1 Answer

What is one thing that you will develop if given a chance to work for facebook?

1 Answer

Design movie ticket booking system (for multiplex theater) with ER diagram. Also give some future extensions

1 Answer

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 Answers

Write an algorithm to find the minimum-depth of a binary tree.

1 Answer