HomeBlog › Goldman Sachs Coding Interview Questions

Goldman Sachs Coding Interview Questions: HackerRank & DS&A

Goldman Sachs runs a HackerRank-first, high-volume process with medium DS&A, some math, and the occasional brain teaser. Four worked problems and the full loop.

Goldman Sachs hires engineers in huge numbers, and its process is built for volume: it usually starts with a HackerRank online assessment of timed coding problems, followed by technical rounds with medium data-structures-and-algorithms, some math or probability, and occasionally a brain teaser. The bar is approachable, but the OA is a real filter and the breadth (CS fundamentals, sometimes finance basics) is wide.

Here's the full loop with four worked problems and how to clear the HackerRank gate.

The full interview process

StageFormatNotes
HackerRank OA60-90 min, 2-3 problemsTimed, auto-graded — the first filter
Technical phone screen30-45 min1-2 medium problems, CS fundamentals
Superday (onsite)Multiple 30-45 min roundsDS&A, math, behavioral, team fit
Hiring manager / fit30-45 minMotivation, why Goldman, division fit

Problem 1: Two Sum (hash map)

Question: Given an array and a target, return indices of the two numbers that add to the target.

One pass with a hash map of value to index; for each number check whether its complement was already seen.

def twoSum(nums, target):
    seen = {}
    for i, num in enumerate(nums):
        if target - num in seen:
            return [seen[target - num], i]
        seen[num] = i
    return []

O(n) time, O(n) space. The complement insight beats the O(n²) double loop — reach it immediately.

Valid Parentheses (stack)

Question: Given a string of brackets, determine if they are validly matched and nested.

Push opening brackets; on a closing bracket, verify it matches the top of the stack. An empty stack at the end means valid.

def isValid(s):
    pairs = {')': '(', ']': '[', '}': '{'}
    stack = []
    for ch in s:
        if ch in pairs:
            if not stack or stack.pop() != pairs[ch]:
                return False
        else:
            stack.append(ch)
    return not stack

O(n) time, O(n) space. Edge cases graded: a closing bracket with an empty stack, and a non-empty stack at the end.

Climbing Stairs (1-D DP)

Question: Climb 1 or 2 steps at a time; count distinct ways to reach step n.

dp[i] = dp[i-1] + dp[i-2] — Fibonacci with O(1) space.

def climbStairs(n):
    prev, curr = 1, 1
    for _ in range(n - 1):
        prev, curr = curr, prev + curr
    return curr

O(n) time, O(1) space. Recognizing the Fibonacci recurrence is the whole point.

Best Time to Buy and Sell Stock

Question: Given daily prices, find the max profit from one buy and one later sell.

Track the minimum price so far; at each day, the best profit is price minus that minimum.

def maxProfit(prices):
    min_price = float('inf'); best = 0
    for p in prices:
        min_price = min(min_price, p)
        best = max(best, p - min_price)
    return best

O(n) time, O(1) space. A sliding-window/greedy hybrid — one pass, no nested loop.

Patterns Goldman Sachs asks most

PatternFrequencyNote
Arrays & hashing~30% of loopsTwo sum, counting, subarrays
Strings / stack~15%Parentheses, parsing
Math / probability~15%Number problems, basic probability
Dynamic programming~15%Stairs, stock, simple sequences
Trees / recursion~15%Traversals
Brain teasers~10%Occasional, stay structured

Common pitfalls specific to Goldman Sachs

A 4-week prep plan for a Goldman Sachs loop

  1. Week 1: Arrays, hashing, and strings under a timer to clear the HackerRank OA.
  2. Week 2: Trees, recursion, and basic DP, plus a refresher on probability basics.
  3. Week 3: Timed mixed sets simulating the OA, and behavioral prep for the Superday.
  4. Week 4: 'Why Goldman' and division-fit stories, plus a solo mock.

Clear the OA with live AI support

CoPilot Interview surfaces structured solutions in about 4 seconds during real Zoom and Teams calls. Free for Windows and macOS, invisible on screen-share.

Download free

FAQ

Does Goldman Sachs use HackerRank?

Yes - the process usually starts with a timed HackerRank online assessment of two to three coding problems that auto-grades your submissions. It's a real filter, so practice timed, auto-graded sets rather than only untimed solving.

How hard are Goldman Sachs coding questions?

Mostly medium data-structures-and-algorithms - arrays, hashing, strings, trees, and basic DP - sometimes mixed with math or probability and the occasional brain teaser. The bar is approachable; the breadth and the timed OA are the challenges.

What is a Goldman Sachs Superday?

The onsite stage: multiple back-to-back 30-45 minute rounds covering coding, math, and behavioral or fit interviews. Managing energy across many short rounds and resetting between them matters as much as raw problem-solving.

Does Goldman Sachs ask math or probability?

Sometimes - number problems and basic probability appear alongside DS&A, reflecting the firm's quantitative culture. A refresher on combinatorics and expected value is worthwhile, though deep quant knowledge isn't required for most engineering roles.

Can CoPilot Interview help me prepare for Goldman Sachs?

Yes. It returns optimal solutions with Big-O in about four seconds, which is ideal for building the speed the HackerRank OA demands. Follow Goldman's stated rules during the live assessment and interviews.