Skip to main content

Goldman Sachs Coding Interview Questions

26 Goldman Sachs coding interview problems with full optimal solutions — 17 easy, 9 medium, 0 hard. Every problem ships with multiple approaches (brute-force first, then the optimal), complexity tables for each, company-specific tips on what an Goldman Sachs interviewer values, and a FAQ section.

Showing 26 problems of 26

  • #1easyfoundational

    1. Two Sum

    Two Sum is Goldman Sachs's most common phone-screen warm-up: given an integer array and a target, return the indices of the two numbers that add up to the target. Goldman uses it to confirm you can articulate the space-for-time tradeoff before writing any code.

    3 free resourcesSolve →
  • #7mediumcompany favorite

    7. Reverse Integer

    Goldman Sachs loves Reverse Integer because it forces you to reason about 32-bit overflow without using a big-integer library. Reverse the digits of a signed integer and return 0 if the reversed value overflows the signed 32-bit range.

    3 free resourcesSolve →
  • #8mediumcompany favorite

    8. String to Integer (atoi)

    Implement atoi: parse a string into a signed 32-bit integer, handling whitespace, sign, digits, and overflow clamping. Goldman Sachs uses atoi specifically because it grades how you handle edge cases — the spec has 5 rules and missing any of them is an instant downgrade.

    2 free resourcesSolve →
  • #9easyfrequently asked

    9. Palindrome Number

    Given an integer x, return true if it reads the same forward and backward. Goldman Sachs uses Palindrome Number to test whether you can solve it without converting to a string — the math-only solution is the actual grade.

    2 free resourcesSolve →
  • #11mediumfrequently asked

    11. Container With Most Water

    Given heights, find two lines that together with the x-axis form the container with the most water. Goldman Sachs uses Container With Most Water to test the two-pointer technique and the proof that 'always move the shorter side' is correct.

    2 free resourcesSolve →
  • #13easyfrequently asked

    13. Roman to Integer

    Convert a Roman numeral string to its integer value. Goldman Sachs uses this as a 10-minute warm-up because it rewards candidates who notice the 'subtractive pair' insight before writing code — interviewers grade the verbal articulation as much as the implementation.

    2 free resourcesSolve →
  • #21easyfoundational

    21. Merge Two Sorted Lists

    Merge two sorted linked lists into one sorted list. Goldman Sachs uses Merge Two Sorted Lists to test the dummy-node pattern — the canonical trick that simplifies head-handling and pointer rewiring.

    2 free resourcesSolve →
  • #50mediumfrequently asked

    50. Pow(x, n)

    Compute x raised to the power n in O(log n). Goldman Sachs uses Pow(x, n) to test 'fast exponentiation' — the moment you say 'I'll square x repeatedly and use the binary representation of n' is the moment they decide to advance you.

    3 free resourcesSolve →
  • #53mediumcompany favorite

    53. Maximum Subarray

    Find the contiguous subarray with the largest sum. Goldman Sachs uses Maximum Subarray to test whether you know Kadane's algorithm by name — the canonical O(n) DP that should come out from muscle memory.

    3 free resourcesSolve →
  • #54mediumfrequently asked

    54. Spiral Matrix

    Return all elements of a matrix in spiral order. Goldman Sachs uses Spiral Matrix to test boundary-tracking discipline — the candidate who articulates the four shrinking boundaries before coding is the one who survives the edge cases.

    2 free resourcesSolve →
  • #66easyfoundational

    66. Plus One

    Increment a non-negative integer represented as an array of digits by one. Goldman Sachs uses Plus One as a warm-up to verify you can handle carry propagation in-place — looks trivial until you hit [9,9,9].

    2 free resourcesSolve →
  • #69easyfrequently asked

    69. Sqrt(x)

    Compute the integer part of sqrt(x) without using a built-in sqrt function. Goldman Sachs uses this to test whether you can implement binary search on the answer space — the fundamental quant interview skill.

    3 free resourcesSolve →
  • #70easyfoundational

    70. Climbing Stairs

    You can climb 1 or 2 stairs at a time; how many ways to reach the top of n stairs? Goldman Sachs uses Climbing Stairs as a DP warm-up — they're grading whether you recognize the Fibonacci recurrence and the O(1) space trick.

    2 free resourcesSolve →
  • #121easycompany favorite

    121. Best Time to Buy and Sell Stock

    Given an array of stock prices by day, find the maximum profit from a single buy-then-sell. As an investment bank, Goldman Sachs uses this exact problem framing in nearly every SWE and Strats loop — the answer is a single-pass O(n) with running minimum.

    3 free resourcesSolve →
  • #122mediumfrequently asked

    122. Best Time to Buy and Sell Stock II

    Multiple buy-sell transactions allowed, can hold at most one share at a time — what's the max profit? Goldman Sachs uses this immediately after the single-transaction variant to test whether you can recognize the 'sum of positive day-to-day deltas' trick.

    2 free resourcesSolve →
  • #136easyfrequently asked

    136. Single Number

    Every element appears twice except for one. Find the single one in O(1) extra space. Goldman Sachs uses Single Number to test the XOR brainteaser — recognizing that a XOR a = 0 is the entire insight.

    3 free resourcesSolve →
  • #168easyfrequently asked

    168. Excel Sheet Column Title

    Given a positive integer, return its corresponding Excel column title (e.g. 28 → 'AB'). Goldman Sachs asks this immediately after Column Number to test whether you noticed why the inverse needs an n-1 correction — most candidates miss it.

    2 free resourcesSolve →
  • #171easyfrequently asked

    171. Excel Sheet Column Number

    Convert an Excel column title like 'AB' to its column number (28). Goldman Sachs uses this base-26 conversion problem to confirm you can derive the closed-form arithmetic without Googling — a foundational skill for the trading-tools team.

    2 free resourcesSolve →
  • #198mediumfrequently asked

    198. House Robber

    Maximize money robbed from a row of houses where you can't rob two adjacent ones. Goldman Sachs uses House Robber to test 'one-dimensional DP with two-state choice' — a recurring quant pattern dressed up as a brainteaser.

    2 free resourcesSolve →
  • #202easycompany favorite

    202. Happy Number

    A number is 'happy' if repeated sum-of-squares-of-digits eventually reaches 1; otherwise the chain enters a cycle. Goldman Sachs uses Happy Number to test cycle detection — the candidate who reaches for Floyd's tortoise-and-hare instead of a hash set earns the bonus point.

    3 free resourcesSolve →
  • #204mediumcompany favorite

    204. Count Primes

    Count the number of primes less than a non-negative integer n. Goldman Sachs uses Count Primes as a sieve question — the candidate who reaches for the Sieve of Eratosthenes instead of trial-division gets the credit.

    3 free resourcesSolve →
  • #206easyfoundational

    206. Reverse Linked List

    Reverse a singly linked list iteratively and recursively. Goldman Sachs uses Reverse Linked List as the canonical 'do you understand pointer manipulation' question — they ask for both the iterative and recursive versions in the same round.

    2 free resourcesSolve →
  • #242easyfrequently asked

    242. Valid Anagram

    Given two strings, determine if one is an anagram of the other. Goldman Sachs uses Valid Anagram as a foundational hash-map question — the candidate who reaches for a 26-int frequency array instead of a generic hash map gets the small-constant credit.

    2 free resourcesSolve →
  • #283easyfrequently asked

    283. Move Zeroes

    Move all zeros to the end of an array while keeping non-zero element order, in-place. Goldman Sachs uses Move Zeroes to test the two-pointer in-place pattern — the candidate who avoids the extra-array detour gets the credit.

    2 free resourcesSolve →
  • #326easyfrequently asked

    326. Power of Three

    Return true if n is a power of three. Goldman Sachs uses this as a brainteaser: they want to see whether you can produce a loop-free, branch-free, O(1) solution that exploits a clever number-theory fact.

    2 free resourcesSolve →
  • #412easyfoundational

    412. Fizz Buzz

    Print 'Fizz' for multiples of 3, 'Buzz' for multiples of 5, 'FizzBuzz' for multiples of 15, otherwise the number. Goldman Sachs uses Fizz Buzz as a 5-minute warm-up — they're grading whether your code is clean, not whether you can solve it.

    2 free resourcesSolve →

Related interview-prep guides

Interview Platforms

HackerRank Tech Interview Guide 2026: What It Tests, How It Tracks You, and the Modern Setup

HackerRank is still the volume leader in first-round technical screens for 2026 tech hiring. A browser-sandboxed coding environment that logs every keystroke, paste event, and tab-focus change inside its own tab. This guide covers what it tests, the boundary of what it can and cannot detect, and how a modern desktop setup pairs with a HackerRank session without leaking into the screen-share.

Interview Process

HireVue Alternatives in 2026: 6 Tools Compared (Candidate-Side Help for Async Video Interviews)

HireVue is an employer-side platform: companies use it to record and AI-score candidate answers. When candidates search for HireVue alternatives they usually mean candidate-side help, not a different employer tool. This guide compares 6 candidate-side options that work during a HireVue interview, ranked honestly against pricing, real-time speech support, coding support, and how visible they are to the recording.

Goldman Sachs Coding Interview Questions — Full Solutions — InterviewChamp.AI