Goldman Sachs Interview Questions

Review this list of 35 Goldman Sachs interview questions and answers verified by hiring managers and candidates.
  • Goldman Sachs logoAsked at Goldman Sachs 
    Video answer for 'Given the root of a binary tree of integers, return the maximum path sum.'

    "\# Definition for a binary tree node. class TreeNode: def init(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def maxPathSum(self, root: TreeNode) -> int: self.max_sum = float('-inf')"

    Jerry O. - "\# Definition for a binary tree node. class TreeNode: def init(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def maxPathSum(self, root: TreeNode) -> int: self.max_sum = float('-inf')"See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • Goldman Sachs logoAsked at Goldman Sachs 
    +10

    "class ListNode: def init(self, val=0, next=None): self.val = val self.next = next def has_cycle(head: ListNode) -> bool: slow, fast = head, head while fast and fast.next: slow = slow.next fast = fast.next.next if slow == fast: return True return False debug your code below node1 = ListNode(1) node2 = ListNode(2) node3 = ListNode(3) node4 = ListNode(4) creates a linked list with a cycle: 1 -> 2 -> 3 -> 4"

    Anonymous Roadrunner - "class ListNode: def init(self, val=0, next=None): self.val = val self.next = next def has_cycle(head: ListNode) -> bool: slow, fast = head, head while fast and fast.next: slow = slow.next fast = fast.next.next if slow == fast: return True return False debug your code below node1 = ListNode(1) node2 = ListNode(2) node3 = ListNode(3) node4 = ListNode(4) creates a linked list with a cycle: 1 -> 2 -> 3 -> 4"See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • Goldman Sachs logoAsked at Goldman Sachs 
    Software Engineer
    System Design
  • Goldman Sachs logoAsked at Goldman Sachs 
    +1

    "As a project or program manager to influence effectively without direct authority, focus on building credibility and trust by consistently delivering results, demonstrating empathy for stakeholder needs, and aligning everyone on shared goals. When managing up, tailor communication to leadership’s priorities and concerns—bring actionable insights, clear data, and potential solutions to the table. When managing down, empower teams by promoting ownership, offering timely recognition, and maintainin"

    Elle M. - "As a project or program manager to influence effectively without direct authority, focus on building credibility and trust by consistently delivering results, demonstrating empathy for stakeholder needs, and aligning everyone on shared goals. When managing up, tailor communication to leadership’s priorities and concerns—bring actionable insights, clear data, and potential solutions to the table. When managing down, empower teams by promoting ownership, offering timely recognition, and maintainin"See full answer

    Data Engineer
    Behavioral
    +2 more
  • Product Manager
    Behavioral
  • 🧠 Want an expert answer to a question? Saving questions lets us know what content to make next.

  • Goldman Sachs logoAsked at Goldman Sachs 
    Software Engineer
    Data Structures & Algorithms
    +4 more
  • "I solved it using recursion and then memoization. Used Dynamic programming approach"

    Ravi teja N. - "I solved it using recursion and then memoization. Used Dynamic programming approach"See full answer

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

    "public class HashMap { public class Element { T key; V value; Element(T k, V v) { this.key = k; this.value = v; } } private static final int DEFAULT_CAPACITY = 16; private static final float LOAD_FACTOR = 0.75f; private LinkedList[] table = new LinkedList[DEFAULT_CAPACITY]; private int size = 0; private int threshold = (int) (DEFAULTCAPACITY * LOADFACTOR); public void put(T k"

    Md kamrul H. - "public class HashMap { public class Element { T key; V value; Element(T k, V v) { this.key = k; this.value = v; } } private static final int DEFAULT_CAPACITY = 16; private static final float LOAD_FACTOR = 0.75f; private LinkedList[] table = new LinkedList[DEFAULT_CAPACITY]; private int size = 0; private int threshold = (int) (DEFAULTCAPACITY * LOADFACTOR); public void put(T k"See full answer

    Software Engineer
    Data Structures & Algorithms
    +2 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
  • "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 
    +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

    Data Engineer
    Data Structures & Algorithms
    +3 more
  • Goldman Sachs logoAsked at Goldman Sachs 

    "standard answer for this."

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

    Software Engineer
    Coding
    +1 more
  • Data Scientist
    Concept
Showing 21-35 of 35