← Back to blog Goldman CoderPad Types: Algorithm, LRU, Matching
Goldman Sachs

Goldman CoderPad Types: Algorithm, LRU, Matching

2026-06-12

CoderPad is Goldman Sachs's preferred coding interview platform. This guide, organized from real candidate debriefs, lays out the four major question types on CoderPad and how to handle them, so your prep lines up with what GS actually tests.


1. Pre-interview preparation

  1. Company & tech research: understand GS business areas (trading, risk, data) and stack (Java, Python, C++).
  2. Practice on CoderPad: get familiar with its interface—running code, debugging, commenting, shortcuts. Don't touch the platform for the first time during the interview.
  3. Review core CS fundamentals: data structures (lists, trees, hash tables) and algorithms (sorting, searching, DP). LeetCode and similar drills are recommended.

2. The four question types

1. Algorithm

Above-average difficulty with real-world twists (e.g., "find all non-repeating subarrays summing to a target"). Use a hash map + two-pointer / prefix sums, explaining the approach first, then writing clean, commented code.

def subarrays_with_sum(nums, target):
    res, prefix = [], 0
    seen = {0: [-1]}                 # prefix sum -> list of left indices
    for r, x in enumerate(nums):
        prefix += x
        for l in seen.get(prefix - target, []):
            res.append(nums[l + 1 : r + 1])
        seen.setdefault(prefix, []).append(r)
    return res

With negatives present you can't use a sliding window; prefix sums + a hash map are the right approach, O(n) overall.

2. Data-structure design

A classic is the LRU cache: get / put must both be O(1). The approach is a hash map + doubly linked list—the hash map locates a node by key, the linked list maintains usage order, the most recently used moves to the head, eviction happens from the tail.

from collections import OrderedDict

class LRUCache:
    def __init__(self, capacity: int):
        self.cap = capacity
        self.cache = OrderedDict()            # key -> value, keeps usage order

    def get(self, key: int) -> int:
        if key not in self.cache:
            return -1
        self.cache.move_to_end(key)           # mark as recently used
        return self.cache[key]

    def put(self, key: int, value: int) -> None:
        if key in self.cache:
            self.cache.move_to_end(key)
        self.cache[key] = value
        if len(self.cache) > self.cap:
            self.cache.popitem(last=False)    # evict least recently used

In the interview, explain why you chose these two structures and the complexity of each operation. If the interviewer asks you to hand-roll the doubly linked list (no OrderedDict), you should be able to implement node insertion / removal on the spot.

3. Code optimization

Given slow code (e.g., an O(n²) nested loop), propose optimizations:

For example, optimizing "two sum" from an O(n²) double loop to a single-pass O(n) hash map is a microcosm of this type.

4. Finance scenarios

Simulate a trading matching engine: handle order creation, matching, and cancellation. Show technical design aligned with the business, including reliability and concurrency.

import heapq

class MatchingEngine:
    def __init__(self):
        self.buys = []    # max-heap: stores (-price, ts, qty)
        self.sells = []   # min-heap: stores (price, ts, qty)

    def submit_buy(self, price, ts, qty):
        while qty > 0 and self.sells and self.sells[0][0] <= price:
            sp, sts, sqty = heapq.heappop(self.sells)
            traded = min(qty, sqty)
            qty -= traded
            if sqty > traded:
                heapq.heappush(self.sells, (sp, sts, sqty - traded))
        if qty > 0:
            heapq.heappush(self.buys, (-price, ts, qty))

3. Sample questions at a glance

4. Summary

The four GS CoderPad question types—algorithm, data-structure design, code optimization, and finance scenarios—span the full spectrum from fundamentals to engineering trade-offs to business modeling. Don't fixate on algorithms alone; practice articulating your structure choices, complexity, and trade-offs.


FAQ

Q1: What kinds of questions does the Goldman Sachs CoderPad interview test?

Four kinds: algorithm (above-average difficulty with real-world twists), data-structure design (e.g., LRU), code optimization (speeding up slow code), and finance scenarios (e.g., a trading matching engine).

Q2: Why does LRU use a hash map + doubly linked list?

The hash map locates nodes in O(1), and the doubly linked list maintains usage order with O(1) moves and eviction. Together they make get/put both O(1). In Python you can simplify with OrderedDict, but be ready to hand-roll the internals.

Q3: What are the key follow-ups on the matching-engine question?

Atomicity under concurrency (locks or single-threaded matching + a queue), fast lookup for cancellations, and idempotency and persistence. Cover reliability and concurrency thoroughly.

Q4: How do you prepare efficiently for GS CoderPad?

Prepare by the four question types, focusing on "explain the idea first, state complexity and trade-offs". For question-type prediction by role line plus timed CoderPad mocks and debriefs, contact oavoservice for a tailored practice plan.


Preparing for the Goldman Sachs CoderPad interview?

The four GS CoderPad question types each have their focus. oavoservice offers full-process GS practice: timed mocks on algorithm / LRU design / code optimization / matching-engine questions, live think-aloud practice on CoderPad, and training in articulating complexity and trade-offs, with question-type prediction by role line. Coaches include senior ex-big-tech engineers who know GS's scoring style.

Add WeChat Coding0201 now to get GS questions and mock practice.

Contact