Senior Engineer Interview Questions in New York City, NY | Glassdoor

# Senior Engineer Interview Questions in New York City, NY

1,112

Senior engineer interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

### Senior Software Engineer at Goldman Sachs was asked...

Dec 3, 2009
 How do you find 2 missing elements in an array of consecutive integers that are not sorted who's size is N-2.7 Answershint sum (n) = n X (n+1)/2One problem with that solution (sum) is that if the sum of numbers is of exorbitant size, you run a risk of overflow, given that there's no limit imposed on N. You can sort the array, but if you don't want modify the user's array, you'll need to make a copy...which depending on the size of the array, might be expensive. An alternative that I thought of would be to create a bitmap for each element (initializing all bits to 1). Then pass through the vector once and set the corresponding bit 0. After one pass through, you can make a second pass to determine which "sectors" still contain set bits and can extrapolate the missing value accordingly. Worst case O(2N) A strategy might be to impose one of the two methods, depending on the size of the array, but sorting inevitably has a floor of O(N), unless you're going to take a probabilistic guess and skip over elements you think might already be sorted. Most algorithms are O(n log n) because the need to visit every element, and the revisiting of some elements to perform the proper placement.http://goldmansachs-is-fraud.blogspot.com/Show More Responsesneed to consider 2 equation s sum of numbers and sum of squaresiterate through array from first to last element and store minimum, maximum and sum as you go. Then take max - min to check if the missing integers are internal or external. If max - min = n -3 then both the missing numbers are the end points. If max - min = n-2 then one missing number is an endpoint, though it would be impossible to determine from which end. If max - min = n-1 then both numbers are consecutive. This should be the most probable result unless n is quite small. We then take the sum of all numbers in the array (which we stored) and from it subtract [(max + min ) * n], which is the sum of all numbers from min to max (including missing numbers). This gives you the sum of the two missing numbers (or one missing number if the other one is external). You have one equation with two unknowns. For the second equation you have several options. Ivan pointed out that the sum of squares will yield a second equation for the same two unknowns.function findMissing2(numbers) { var missing = []; var delta; var currentNumber; numbers.sort(function(a,b){ return a - b; }); console.log(numbers); for(var i=0; i 2) { throw new Error("there are more than 2 numbers missing in the sequence"); } else if(missing.length == 0) { missing.push(numbers[0]-1, numbers[0]-2); } return missing; }Find my complete discussion here http://www.capacode.com/array/find-2-missing-numbers-in-array/ If we use boolean of array to store numbers in A, then this problem is simple. It runs in O(N) and use O(N) memory. How to optimize memory here? First, we can easily find the sum of two missing numbers which is (N * (N + 1) / 2 ) – Sum(A). For example, given the problem, sum of two missing numbers is 5. We need another information to find two missing numbers. We can similar compute the product of two numbers which is N! / Product(A). After having sum and product of two numbers, we can easily find those numbers. However, the problem is N! can be large and overflow. We can similar find the xor of two missing numbers. Just Xor all number in A with all numbers from 1 to N. However, Xor and Sum operator are quite similar and they can not find to which number missing. Next is the best efficient solution as I know. We know sum of two numbers, for example, in this case is 5. Thus, one number must be less than or equal 2 and one number must be greater than or equal 3. So, next we just compute sum of all number less than or equal 2, and sum of all number greater than or equal 3. Finally we can find two missing number. Specifically, first sum is 1, second sum is 4 + 5 = 9. However, in complete array, first sum should be 1 + 2 = 3, second sum should be 3 + 4 + 5 = 12. Thus two missing number is 2 and 3 :)

### Senior Software Engineer at Thomson Reuters was asked...

Jan 19, 2012
 find common numbers in 2 arrays of integer, try to use O(N).3 AnswersUse HashMapyou could use set_intersection in STL to find the common numbers, but the arrays should be sorted, this would give O(m+n).function findCommon(arr1, arr2) { var seen = {}; var common = []; for ( var i =0; i < arr1.length; i++) { seen[arr1[i]] = 1; } for ( var i =0; i < arr2.length; i++) { if (seen[arr2[i]] === 1) { common.push(arr2[i]); seen[arr2[i]]++; } } return common; }

### Senior Software Engineer at Bloomberg L.P. was asked...

May 23, 2012
 What happens when a constructor fails. And then what happens when a distructor fails.2 AnswersI told him that you get an exception when a constructor fails and a null pointer is returned. This did not seem to satisfy him. As far as a distructor failing it makes no sense since how can it fail, it is only releasing items that was used when the object was created. It should not fail and if it did then you have problems in the code. He did not like this answer either. Makes no sense.Constructors can fail when they try to acquire a resource that is not available, like memory, a file handle, a screen window, etc. If new fails, it'll throw std::bad_alloc. If the constructor doesn't catch it, then that will propagate out of the constructor. C++ has no good way to deal with errors in a destructor. To the extent possible, you should design destructors to not fail. You should never throw an exception from a destructor. And if a function you call in a destructor might throw an exception, you should either catch it (if you know it's safe to ignore) or crash immediately.

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

Mar 9, 2011
 Explain how the garbage collector works. 2 AnswersIt is the systematic recovery of heap memory, by tracking usage of references to that memory. The recovery (freeing) can occur either immediately when the last reference goes out of scope or later by other defined parameters such as when allocated space reaches a certain threshold or the system is idle. The exact functionality depends upon the implementation.A generic explanation could be: 1-During the first pass GC marks in the heap the objects that are eligible to be freed, if all the references they hava are null. 2-GC deletes all marked objects in the heap. 3-The heap is compacted by the JVM to avoid memory fragmentation.

### Senior Software Engineer at Jet was asked...

Aug 5, 2015
 Write an algorithm to determine if a string is a palindrome.2 AnswersWith a good algorithm.string pal = "abcba"; bool isPalindrome = true; int length = pal.Length; for (int i = 0; i < (int)length / 2; i++) { if (pal[i] != pal[length - i - 1]) { isPalindrome = false; break; } }

### Senior Software Engineer at EC Infosystems was asked...

Oct 20, 2015
 what did you work today in office1 Answeri told my current task

### Senior Sales Engineer at Verizon was asked...

Mar 20, 2015
 How do you install a PBX.1 AnswerI told him How.

### Senior Software Engineer at Teachable was asked...

Apr 17, 2019
 design a comment section database and design a trello ish app1 Answerdescribed how i would design both problems

### Senior Network Engineer at Pandora Media, LLC was asked...

Mar 20, 2014
 What are DNS glue records?1 AnswerIP address records for upstream Name resolvers

### Senior Backend Engineer at Uber was asked...

Apr 12, 2019
 What are some things to take note of when designing distributed services1 AnswerHigh availability, minimizing single points of failure, using resilient architecture
110 of 1,112 Interview Questions