Hi everyone, I recently completed the 2026 Goldman Sachs Coding Interview. The interview mainly focuses on real coding ability, data structure design, and problem-solving under pressure. This article shares the actual questions I encountered along with detailed explanations and Python solutions.
Goldman Sachs interviews are typically LeetCode Medium level, sometimes involving design problems or business-style scenarios. Interviewers pay close attention to communication, edge cases, and code readability.
Problem 1: Transaction Segments
Problem Summary:
Given an array of transaction amounts and an integer k, count how many contiguous subarrays of length exactly k are strictly increasing.
Key Idea:
Use a sliding window or linear scan to check each subarray of size k and verify strict increasing order.
Problem 2: Efficient Tasks
Problem Summary:
Assign modules to 3 servers under constraints, and maximize the minimum value among all assignments.
Key Idea:
This is a classic “maximize the minimum” problem, typically solved using binary search combined with greedy validation or dynamic programming.
Problem 3: Design HashMap
Problem Statement:
Design a HashMap without using built-in hash table libraries.
Implement the following operations:
- MyHashMap() - initialize the data structure
- put(key, value) - insert or update a key-value pair
- get(key) - return value or -1 if not found
- remove(key) - delete key if exists
Solution Idea
We use chaining to handle collisions. The structure contains a fixed-size bucket array, where each bucket stores key-value pairs.
- Hash function: key % bucket_size
- Collision handling: list-based chaining
- Operations: linear search within each bucket
Python Implementation
class MyHashMap:
def __init__(self):
self.bucket_count = 10007
self.hash_map = [[] for _ in range(self.bucket_count)]
def _hash(self, key: int) -> int:
return key % self.bucket_count
def put(self, key: int, value: int) -> None:
index = self._hash(key)
for i, (k, v) in enumerate(self.hash_map[index]):
if k == key:
self.hash_map[index][i] = (key, value)
return
self.hash_map[index].append((key, value))
def get(self, key: int) -> int:
index = self._hash(key)
for k, v in self.hash_map[index]:
if k == key:
return v
return -1
def remove(self, key: int) -> None:
index = self._hash(key)
for i, (k, v) in enumerate(self.hash_map[index]):
if k == key:
del self.hash_map[index][i]
return
Complexity
- Average Time: O(1)
- Worst Case: O(n)
- Space: O(n)
Interview Tips
- Focus on explaining edge cases clearly
- Communicate while coding
- Expect follow-ups on rehashing and load factor
- Practice LeetCode Medium problems (Array, DP, Greedy, Design)
Good luck with your Goldman Sachs interview preparation!
Top comments (0)