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

# Senior Software Engineer Interview Questions in New York, NY

"Senior software engineers are the most experienced member of a software team and usually carry the most responsibility and authority of that team. Because of this, interviews will be designed to find candidates who have expert knowledge of the field and years of experience as a software engineer. Expect to be asked tough technical questions and to give examples of previous projects that you have worked on."

## 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 Socure was asked...

Jun 26, 2019
 give a table, select the 10th highest record.1 AnswerI give the right sql query which can execute in mysql, but their engineers seems has little knowledge on mysql and told me that my answer was wrong.

### 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 Software Engineer at S&P Global Ratings was asked...

Mar 10, 2011
 Regular Expression syntax questions.1 AnswerYou could either remember the exact syntax or not.

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

Mar 29, 2019
 Look at this generic traffic graph, what does it tell you1 AnswerIt tells you nothing without knowing anything about the application or it's purpose..

### Senior Software Engineer at Samsung Research America was asked...

Dec 2, 2014
 Build in Scala a datatype similar to defaultdict in python1 AnswerThis is a tricky type system question. If your dict is immutable, it's easy, cause you can just have a default immutable object. If your dict is mutable, things get interesting

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

Apr 27, 2019
 Puzzler (2D 5x4 Array) search word horizontally, vertically and diagonally. (Easy)1 Answerpuzzle = [ ['a', 'b', 'c', 'c', 'a', 'r'], ['a', 'r', 'e', 'o', 'o', 'e'], ['t', 'e', 'a', 'a', 'r', 'r'], ['o', 'a', 'c', 'c', 'r', 'e'], ['e', 'd', 'r', 'c', 'f', 'e'], ] word_1 = "car" word_2 = "bear" word_3 = "tea" word_4 = "toe" word_5 = "core" word_6 = "hello" word_7 = "tar" word_8 = "bread" def search_word(puzzle, word) search_horizontal(puzzle, word) || search_vertical(puzzle, word) || search_diagonal(puzzle, word) end # Searches diagonal from left to right def search_diagonal(puzzle, word) cols = 0..5 rows = 0..4 new_word = "" chars = word.chars cols.each.with_index do |col| rows.each do |row| if puzzle[row][col] == chars.first new_word << puzzle[row][col] current_row = row + 1 current_col = col + 1 while current_row <= 4 if current_col <= 5 new_word << puzzle[current_row][current_col] end current_col += 1 current_row += 1 end return true if new_word.include? word new_word = "" end end end false end def search_horizontal(puzzle, word) chars = word.chars size = chars.size puzzle.each do |row| row.each.with_index do |l, i| return true if row[i..i+size].join.include? word end end false end def search_vertical(puzzle, word) cols = 0..5 rows = 0..4 new_word = "" chars = word.chars cols.each do |col| rows.each do |row| new_word << puzzle[row][col] end return true if new_word.include? word new_word = "" end false end p search_word(puzzle, word_1) == true p search_word(puzzle, word_2) == true p search_word(puzzle, word_3) == true p search_word(puzzle, word_4) == true p search_word(puzzle, word_5) == true p search_word(puzzle, word_6) == false p search_word(puzzle, word_7) == true p search_word(puzzle, word_8) == true
110 of 835 Interview Questions