Goldman Sachs Software Engineer Interview Questions

Review this list of 27 Goldman Sachs software engineer interview questions and answers verified by hiring managers and candidates.
  • Goldman Sachs logoAsked at Goldman Sachs 
    +37

    "#include // Naive method to find a pair in an array with a given sum void findPair(int nums[], int n, int target) { // consider each element except the last for (int i = 0; i < n - 1; i++) { // start from the i'th element until the last element for (int j = i + 1; j < n; j++) { // if the desired sum is found, print it if (nums[i] + nums[j] == target) { printf("Pair found (%d, %d)\n", nums[i], nums[j]); return; } } } // we reach here if the pair is not found printf("Pair not found"); } "

    Gundala tarun,cse2020 V. - "#include // Naive method to find a pair in an array with a given sum void findPair(int nums[], int n, int target) { // consider each element except the last for (int i = 0; i < n - 1; i++) { // start from the i'th element until the last element for (int j = i + 1; j < n; j++) { // if the desired sum is found, print it if (nums[i] + nums[j] == target) { printf("Pair found (%d, %d)\n", nums[i], nums[j]); return; } } } // we reach here if the pair is not found printf("Pair not found"); } "See full answer

    Software Engineer
    Data Structures & Algorithms
    +5 more
  • Goldman Sachs logoAsked at Goldman Sachs 
    Software Engineer
    Data Structures & Algorithms
    +4 more
  • Goldman Sachs logoAsked at Goldman Sachs 
    Software Engineer
    Data Structures & Algorithms
    +2 more
  • "Construct a min-heap either inplace, or by making a copy of the array and then applying heapify on that copy. This is done in O(n) time. Maintain two zero-initialised variables - sum and count. Keep popping off the heap while sum < k, and update count. In the worst case you will have to do n pops, and each pop is O(log n), so the algorithm would take O(n log n) in total. Space complexity depends on whether you're allowed to modify inplace or not, so either O(1) or O(n) respectively."

    Anonymous Wolf - "Construct a min-heap either inplace, or by making a copy of the array and then applying heapify on that copy. This is done in O(n) time. Maintain two zero-initialised variables - sum and count. Keep popping off the heap while sum < k, and update count. In the worst case you will have to do n pops, and each pop is O(log n), so the algorithm would take O(n log n) in total. Space complexity depends on whether you're allowed to modify inplace or not, so either O(1) or O(n) respectively."See full answer

    Software Engineer
    Coding
    +1 more
  • Goldman Sachs logoAsked at Goldman Sachs 
    +7

    "function trapRainWater(height) { if (height.length = leftTrap || leftPosition >= heightLimit) { leftTrap = leftPosition; heightLimit = Math.min(le"

    Tiago R. - "function trapRainWater(height) { if (height.length = leftTrap || leftPosition >= heightLimit) { leftTrap = leftPosition; heightLimit = Math.min(le"See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • 🧠 Want an expert answer to a question? Saving questions lets us know what content to make next.

  • Goldman Sachs logoAsked at Goldman Sachs 

    "standard answer for this."

    Shar N. - "standard answer for this."See full answer

    Software Engineer
    Coding
    +1 more
  • Goldman Sachs logoAsked at Goldman Sachs 
    +6

    "function isPalindrome(s, start, end) { while (s[start] === s[end] && end >= start) { start++; end--; } return end <= start; } function longestPalindromicSubstring(s) { let longestPalindrome = ''; for (let i=0; i < s.length; i++) { let j = s.length-1; while (s[i] !== s[j] && i <= j) { j--; } if (s[i] === s[j]) { if (isPalindrome(s, i, j)) { const validPalindrome = s.substring(i, j+1"

    Tiago R. - "function isPalindrome(s, start, end) { while (s[start] === s[end] && end >= start) { start++; end--; } return end <= start; } function longestPalindromicSubstring(s) { let longestPalindrome = ''; for (let i=0; i < s.length; i++) { let j = s.length-1; while (s[i] !== s[j] && i <= j) { j--; } if (s[i] === s[j]) { if (isPalindrome(s, i, j)) { const validPalindrome = s.substring(i, j+1"See full answer

    Software Engineer
    Data Structures & Algorithms
    +3 more
Showing 21-27 of 27