Goldman Sachs interview questions

1,512 questions from 156 interviews · updated from reports 2012-2025

Practise Goldman Sachs-style

About

Goldman Sachs is a financial services firm offering investment banking, markets, asset management, and wealth management services. In India, it often hires software engineers, software engineering interns, and interns for technology teams working on trading, risk, data, and finance systems.

The roles that come up most are Software Engineer, Software Engineering Intern and Intern. This covers 156 candidate interviews reported from 2012 to 2025. The largest group sat it at internship level (58 of 149 that recorded a level). Among the 126 that recorded either route, arrivals split between campus drives (65, 52%) and off-campus applications (61, 48%). Most questions fall under DSA and CS fundamentals.

Category
Difficulty
Round

Interview questions

Q. Find the first non-repeating character in a string.

asked 13xeasyStringsOnline test, Technical2015-2024

Ans. Scan the string to count each character, then scan it again and return the first character whose count is one. Use a hash map or fixed-size frequency array, depending on the character set. This keeps the order check simple and runs in O(n) time with O(k) space, where k is the number of distinct characters.

Q. Detect and remove a loop in a linked list.

asked 5xmediumLinked listsTechnical2015-2023

Ans. Use Floyd’s slow and fast pointer method to detect the loop, then remove it by finding the node where the cycle starts and setting the previous node’s next pointer to null. After slow and fast meet, move one pointer to head and advance both one step at a time. Time is O(n), space is O(1).

Q. Reduce a string by removing K consecutive identical characters

asked 4xmediumStringsManagerial, Online test, Technical2020-2024

Ans. Use a stack of pairs, where each pair stores a character and its current consecutive count. Scan the string left to right, incrementing the top count when the character matches, otherwise pushing a new pair. When a count reaches K, pop it. Rebuild the answer from the stack. Time is O(n), space is O(n).

Q. Explain the Singleton design pattern

asked 4xeasyOOPSystem design, Technical2016-2021

Ans. The Singleton pattern ensures a class has exactly one instance and provides a global access point to it. It is usually implemented with a private constructor and a static method or property returning the instance. The key detail is thread safety, especially if the instance is created lazily in a multi-threaded program.

Q. Design and implement an LRU Cache

asked 3xmediumDesignTechnical2016-2021

Ans. Implement an LRU cache with a hash map from key to list node and a doubly linked list ordered by recent use. On get, return the value and move the node to the front. On put, update or insert at the front. If capacity is exceeded, remove the tail. Both operations are O(1).

Q. Find the longest palindromic substring in a given string

asked 3xmediumStringsTechnical2019-2021

Ans. Use expand around centres: for each index, expand once for an odd-length palindrome and once between indices for an even-length palindrome, tracking the best start and length. The key detail is handling both centre types. This uses only a few variables, runs in O(n squared) time, and uses O(1) extra space.

Q. Minimum Number of Platforms Required for a Railway/Bus Station

asked 3xmediumArraysTechnical2019-2021

Ans. The minimum number of platforms is the maximum number of trains or buses present at the station at the same time. Sort arrival and departure times separately, then scan them with two pointers, increasing the count on an arrival and decreasing it on a departure. Track the maximum count. Time complexity is O(n log n), space is O(1) besides sorting.

Q. Find the median of two sorted arrays.

asked 3xhardBinary searchTechnical2020-2024

Ans. Use binary search on the smaller array to find a partition where the left halves of both arrays contain half the total elements and every left value is less than or equal to every right value. The median is then the max of left values, or the average of max left and min right. Time is O(log min(m,n))).

Q. Implement a queue using two stacks.

asked 3xeasyStacks queuesTechnical2014-2021

Ans. Use two stacks, one for incoming elements and one for outgoing elements. Enqueue pushes onto the incoming stack. Dequeue pops from the outgoing stack; if it is empty, move all elements from incoming to outgoing first. This reverses order correctly. Each operation is amortised O(1), with O(n) extra space.

Q. Reading comprehension questions based on passages

asked 3xeasyVerbalOnline test2021-2023

Ans. Read the questions first to know what to look for, then read the passage carefully. Identify the main idea, tone, and key details. For each question, return to the exact part of the passage that supports the answer. Avoid using outside knowledge, and eliminate options that distort, exaggerate, or contradict the text.

Q. Maximum path sum in a matrix

asked 2xmediumDynamic programmingOnline test, Technical2021

Ans. Use dynamic programming, where each cell stores the maximum sum achievable when reaching that cell from the row above. For the common version, moves are down, down-left and down-right, so dp[i][j] equals matrix[i][j] plus the maximum valid previous value. The answer is the maximum value in the last row. Time complexity is O(nm).

Q. Design a Library Management System

asked 2xmediumLow level designTechnical2017-2021

Ans. Design it around books, copies, members, loans, reservations and fines, with APIs for search, checkout, return and renewal. The key detail is copy-level state, not book-level state, so each physical item can be available, borrowed, reserved or lost. Use transactions to prevent double checkout and maintain accurate inventory.

Q. Explain the HashMap contract in Java.

asked 2xmediumOOPManagerial, Technical2020

Ans. A Java HashMap relies on the equals and hashCode contract for its keys: equal keys must have the same hash code, and equals must be consistent. HashMap uses hashCode to find a bucket and equals to identify the exact key. Mutating key fields used in these methods can make entries unreachable.

Q. Explain the internal working of HashMap.

asked 2xmediumOOPTechnical2020-2021

Ans. A HashMap stores key value pairs in an array of buckets, using the key’s hash code to choose a bucket index. If two keys map to the same bucket, it handles the collision, commonly with a linked list or tree. When the load factor grows too high, it resizes and rehashes. Average access is constant time.

Q. How does HashMap work internally in Java?

asked 2xmediumCollectionsTechnical2016-2019

Ans. HashMap stores key value pairs in an array of buckets, using the key’s hashCode to choose a bucket index. If keys collide, entries share the bucket, first as a linked list and, in Java 8+, as a balanced tree when large enough. Lookup then checks hash and equals. Average operations are O(1).

Q. Reverse a linked list in groups of size k.

asked 2xmediumLinked listsTechnical2021

Ans. Reverse each block of k nodes by rewiring next pointers, then connect the previous block’s tail to the new head of the reversed block. Use three pointers to reverse a block in place, and first check that k nodes remain if partial groups should stay unchanged. Time complexity is O(n), space complexity is O(1).

Q. Explain the internal working of HashMap in Java.

asked 2xmediumJavaTechnical2020

Ans. A HashMap stores key value pairs in an internal array of buckets, using the key’s hashCode to choose a bucket index. If multiple keys land in the same bucket, it compares keys with equals and stores collisions in a linked list or, after enough collisions, a tree. Resizing happens when the load factor threshold is crossed.

Q. Find the longest palindromic subsequence in a string

asked 2xmediumDynamic programmingTechnical2021

Ans. Use dynamic programming where dp[i][j] stores the length of the longest palindromic subsequence inside s[i..j]. If s[i] equals s[j], set it to 2 plus dp[i+1][j-1], otherwise take the maximum of excluding either end. Fill by increasing substring length. Time is O(n²), space is O(n²).

Q. What is multithreading and how is it implemented in Java?

asked 2xmediumOperating systemsTechnical2015-2023

Ans. Multithreading is running multiple threads within one process so tasks can make progress concurrently and share the same memory space. In Java it is implemented using the Thread class, Runnable or Callable tasks, and usually ExecutorService thread pools. Shared data must be protected with synchronisation tools such as synchronized, locks, or concurrent collections.

Q. Check if a number can be written as a sum of K prime numbers

asked 2xmediumMathOnline test2021

Ans. Return true if N is at least 2K, except when K is 1, where N itself must be prime. The key detail is that the smallest possible sum is K copies of 2, so N < 2K is impossible. For K greater than 1, the usual Goldbach-based interview assumption accepts the rest.

Q. Find the smallest subarray with sum greater than a given value

asked 2xmediumArraysTechnical2020-2021

Ans. Use a sliding window to keep the smallest length whose sum is greater than the given value. Expand the right end while the sum is too small, then shrink the left end while the sum remains greater, updating the best length. This works for positive numbers in O(n) time and O(1) space.

Q. Find the maximum of all subarrays of size K using a sliding window.

asked 2xmediumArraysTechnical2021

Ans. Use a sliding window with a double ended queue storing indices of useful elements in decreasing value order. For each new element, remove smaller elements from the back, remove indices outside the window from the front, then the front is the maximum. This runs in O(n) time and O(k) space.

Q. Find the maximum sum path in a matrix from bottom-left to top-right

asked 2xmediumDynamic programmingTechnical2019-2024

Ans. Use dynamic programming, since each cell’s best path depends only on previous reachable cells. Starting at the bottom-left, fill a DP table where each cell stores the maximum sum to reach it, using the best of the cell below and the cell to the left. The answer is at the top-right. Time is O(rows × columns).

Q. Find the minimum length subarray with sum greater than a given value

asked 2xmediumArraysOnline test, Technical2019-2020

Ans. Use a sliding window to keep the smallest contiguous subarray whose sum is greater than the target. Expand the right end, adding elements, then while the sum is greater than the target, update the minimum length and shrink from the left. This uses constant extra space and runs in O(n) time for positive numbers.

Q. Convert a Binary Search Tree to a sorted doubly linked list in place.

asked 2xmediumTreesTechnical2017-2020

Ans. Do an in-order traversal and relink each visited node so its left pointer points to the previous node and its right pointer points to the next node. Keep two references, head for the first node and prev for the last processed node. This is in place, takes O(n) time, and uses O(h) recursion stack.

Q. Given an array of numbers, arrange them to form the largest possible number

asked 2xmediumSortingTechnical2017-2020

Ans. Convert the numbers to strings and sort them so that for any two strings a and b, a comes before b if ab is larger than ba. Then concatenate the sorted strings. The key detail is the custom comparator, not numeric value. If the first result character is 0, return 0. Sorting costs O(n log n).

Q. Minimum number of platforms required for a railway/bus station given arrival and departure times

asked 2xmediumGreedyTechnical2021

Ans. Sort arrival times and departure times separately, then scan both lists with two pointers, counting platforms in use and tracking the maximum count. When the next arrival is before or equal to the next departure, add a platform; otherwise free one. This uses arrays only and runs in O(n log n) time.

Q. Given an array of N integers in the range [a, b] with five numbers missing, find the five missing numbers.

asked 2xmediumArraysTechnical2015-2020

Ans. Use a bitset indexed by value minus a, mark every number present in the array, then scan the range [a, b] and output the five unmarked values. The key detail is offsetting indices by a. This takes O(N + b - a + 1) time and O(b - a + 1) space.

Q. Egg Dropping Puzzle

asked 2xhardDynamic programmingTechnical2017-2020

Ans. Use dynamic programming to find the minimum worst case drops needed for e eggs and f floors. The key recurrence tries each floor x and takes 1 plus the maximum of egg breaks below and survives above, then minimises over x. A standard DP table costs O(e f²) time and O(e f) space.

Q. Trapping Rain Water

asked 2xhardArraysTechnical2020

Ans. Use two pointers from both ends, tracking the maximum height seen on the left and right. Move the side with the smaller current height, because its trapped water is limited by that side’s maximum. Add max minus current height when positive. This uses constant space and runs in O(n) time.

Q. Find the median of a stream of running integers

asked 2xhardHeapsSystem design, Technical2021-2024

Ans. Use two heaps: a max heap for the lower half of numbers and a min heap for the upper half. Insert each new number into the correct heap, then rebalance so their sizes differ by at most one. The median is the larger heap’s top, or the average of both tops. Insert is O(log n), median is O(1).

Q. Explain Java 8 features

asked 2xeasyOOPManagerial, Technical2016-2017

Ans. Java 8 introduced lambdas, functional interfaces, the Stream API, default and static methods in interfaces, Optional, the new java.time date and time API, and CompletableFuture improvements. The most important change is lambdas plus streams, which allow concise functional-style processing of collections with operations like map, filter and reduce.

Q. Explain OOP concepts in Java.

asked 2xeasyOOPTechnical2016-2017

Ans. OOP in Java is based on objects that combine data and behaviour, mainly using encapsulation, inheritance, polymorphism and abstraction. Encapsulation hides state behind methods, inheritance reuses and extends classes, polymorphism lets the same interface call different implementations, and abstraction exposes essential behaviour through abstract classes or interfaces.

Q. Explain the final keyword in Java.

asked 2xeasyOOPTechnical2016-2017

Ans. The final keyword in Java prevents further change to a variable, method, or class in a specific way. A final variable cannot be reassigned, a final method cannot be overridden, and a final class cannot be extended. For object references, final fixes the reference, not the object’s internal state.

Q. Detect a loop in a doubly linked list

asked 2xeasyLinked listsTechnical2019-2020

Ans. Use Floyd’s cycle detection on the next pointers: move a slow pointer one step and a fast pointer two steps, and a loop exists if they ever meet. If fast reaches null, there is no loop. This uses no extra data structure, runs in O(n) time, and uses O(1) space.

Q. Find the middle of a linked list in one pass.

asked 2xeasyLinked listsTechnical2020

Ans. Use two pointers: a slow pointer moves one node at a time and a fast pointer moves two nodes at a time. When the fast pointer reaches the end, the slow pointer is at the middle. This needs no extra data structure, runs in O(n) time, and uses O(1) space.

Q. Find the intersection point of two linked lists

asked 2xeasyLinked listsTechnical2013-2020

Ans. Use two pointers, one on each list, and advance them one node at a time; when a pointer reaches the end, move it to the head of the other list. If the lists intersect, the pointers meet at the intersection node after equalised traversal. This uses constant extra space and runs in O(m + n) time.

Q. Implement Run Length Encoding for a given string

asked 2xeasyStringsOnline test, Technical2020

Ans. Scan the string once, count consecutive equal characters, and append each character followed by its count to a result builder when the character changes. Use a mutable string builder or list to avoid repeated string concatenation. After the loop, append the final run. This takes O(n) time and O(n) space.

Q. What are the differences between C++ and Python?

asked 2xeasyProgramming languagesHR, Technical2020-2021

Ans. C++ is a compiled, statically typed language focused on performance and control, while Python is an interpreted, dynamically typed language focused on simplicity and fast development. The most important difference is that C++ gives manual control over memory and hardware-level details, whereas Python manages memory automatically but is usually slower.

Q. Explain polymorphism in Object-Oriented Programming

asked 2xeasyOOPTechnical2020-2021

Ans. Polymorphism is the ability to treat different object types through the same interface while each type provides its own behaviour. For example, different shapes can all have an area method, but each calculates it differently. The key benefit is writing flexible code that depends on common behaviour rather than specific concrete classes.

Q. Explain the difference between a process and a thread

asked 2xeasyOperating systemsTechnical2021

Ans. A process is an independent running program with its own memory space, while a thread is a smaller unit of execution within a process that shares that process’s memory. Processes are more isolated and cost more to create or switch between. Threads are lighter, but shared memory makes synchronisation and race conditions important.

Q. Explain the difference between == and equals() in Java.

asked 2xeasyOOPTechnical2019-2020

Ans. == compares primitive values, but for objects it compares whether two references point to the same object. equals() is a method used to compare logical equality between objects. The key detail is that Object.equals() behaves like == by default, so classes such as String override it to compare contents instead.

Q. Explain method overloading and method overriding in Java.

asked 2xeasyOOPTechnical2016-2019

Ans. Method overloading means defining methods with the same name but different parameter lists in the same class, while method overriding means a subclass provides its own implementation of a superclass method with the same signature. Overloading is resolved at compile time, whereas overriding is resolved at runtime through dynamic dispatch.

Q. Explain the contract between hashCode() and equals() in Java.

asked 2xeasyHashingTechnical2016-2019

Ans. If two objects are equal according to equals(), they must return the same hashCode(). Objects with the same hashCode() do not have to be equal, because collisions are allowed. When overriding equals(), you must also override hashCode(), otherwise hash-based collections like HashMap and HashSet can behave incorrectly.

Q. Search an element in a row-wise and column-wise sorted matrix.

asked 2xeasyArraysTechnical2016-2019

Ans. Start from the top-right element and eliminate one row or one column at a time. If the current value equals the target, return found. If it is greater, move left. If it is smaller, move down. This works because rows and columns are sorted. Time complexity is O(m + n), space is O(1).

Q. Rotate a given matrix by 90 degrees in anti-clockwise direction

asked 2xeasyArraysOnline test2021

Ans. Rotate the square matrix 90 degrees anti-clockwise by first transposing it, then reversing each column. The key detail is doing it in place, so no extra matrix is needed. This uses the matrix itself as the data structure, runs in O(n²) time, and uses O(1) extra space.

Q. What is the difference between pointers and reference variables in C++?

asked 2xeasyOOPTechnical2015-2023

Ans. A pointer stores the address of an object, while a reference is an alias for an existing object. A pointer can be null, reassigned, and needs dereferencing to access the value. A reference must be initialised when declared, normally cannot be rebound, and is used like the original variable.

Q. Explain the difference between an interface and an abstract class in Java.

asked 2xeasyOOPTechnical2015-2023

Ans. An abstract class is a partial base class, while an interface is mainly a contract a class agrees to implement. An abstract class can hold instance state, constructors, and concrete methods, but a class can extend only one. A class can implement multiple interfaces, which is useful for defining shared capabilities.

Q. 100 Doors puzzle

asked 1xmediumLogical reasoningTechnical2020

Ans. Only the doors with square numbers stay open: 1, 4, 9, 16, 25, 36, 49, 64, 81 and 100. A door is toggled once for each divisor it has. Divisors normally come in pairs, so the door ends closed. Square numbers have one unpaired divisor, their square root, so they are toggled an odd number of times.

Q. Gold bar puzzle.

asked 1xmediumLogical reasoningTechnical2015

Ans. Cut the seven-unit bar into pieces of 1, 2, and 4 units using two cuts. Pay one unit on day one, swap it for the 2-unit piece on day two, add the 1-unit piece on day three, swap both for the 4-unit piece on day four, then combine pieces to make five, six, and seven.

Q. 8 marbles puzzle.

asked 1xmediumLogical reasoningTechnical2015

Ans. Weigh three marbles against three. If they balance, the heavier marble is among the two not weighed, so weigh those two and pick the heavier. If the first weighing does not balance, take the heavier group of three and weigh one against one. If they balance, the third is heavier; otherwise the heavier side is the answer.

Q. Two pills puzzle.

asked 1xmediumLogical reasoningTechnical2015

Ans. Cut every pill in half, and take one half of each pill today. Keep the matching halves for tomorrow. Since there are two pills of each type, each day you get half of every pill, which totals one full dose of each medicine. You never need to identify which pill is which.

Q. Set Matrix Zeroes.

asked 1xmediumArraysTechnical2020

Ans. Use the first row and first column as markers to record which rows and columns must become zero. First, store whether the first row or column originally contains zero, then mark using the remaining cells, zero marked rows and columns, and finally handle the first row and column. Time is O(mn), space is O(1).

Q. Bag of coins puzzle.

asked 1xmediumLogical reasoningTechnical2019

Ans. Number the bags 1 to 10. Take 1 coin from bag 1, 2 from bag 2, and so on, then weigh all 55 coins together. If all were genuine, they would weigh 550 grams. The shortfall tells you the fake bag: 3 grams short means bag 3, 7 grams short means bag 7.

Q. Design a rate limiter API

asked 1xmediumLow level designSystem design2021

Ans. Expose a rate limit check API that takes a client key, limit, window and cost, and returns allow or reject with remaining quota and retry time. Use a token bucket per key in Redis, refilled from timestamps using atomic Lua scripts. This supports bursts, is distributed, and gives constant time checks.

Q. Find the tens digit of 2^130.

asked 1xmediumNumber theoryManagerial2020

Ans. The tens digit is 2. To find a tens digit, work modulo 100, since the last two digits determine it. Powers of 2 modulo 100 repeat every 20. Since 130 leaves remainder 10 when divided by 20, use 2^10 = 1024, whose last two digits are 24.

Q. Probability-based puzzle problem

asked 1xmediumProbabilityTechnical2019

Ans. Start by defining the possible outcomes and checking whether they are equally likely. Count favourable outcomes and total outcomes, then use probability equals favourable divided by total. For multi-step events, use conditional probability or a tree diagram. Watch for wording such as at least, exactly, and given that, as these change the calculation.

Q. Has technology taken over us or have we taken over technology?

asked 1xmediumVerbalGroup discussion2014

Ans. A strong answer takes a balanced view: technology shapes behaviour, but people remain responsible for how it is used. Pick a work example where technology improved outcomes but needed judgement, ethics, or boundaries. Emphasise adaptability, critical thinking, and accountability. Interviewers listen for maturity, not fear of technology or blind enthusiasm.

Q. For a project or assignment, describe a time you faced a major obstacle and what was the most exciting part of working on it.

asked 1xmediumProblem solvingManagerial2021

Ans. Pick a real project with a clear obstacle, such as a tight deadline, technical issue, missing information, or team conflict. Emphasise your actions, judgement, and persistence, not just the problem. Explain the result and what excited you, such as solving uncertainty, learning fast, or seeing the work create impact.

Q. In a two-person team project, how would you handle the situation if the other member faces a personal problem and cannot continue?

asked 1xmediumTeamworkOnline test2021

Ans. A strong answer should show empathy, ownership, and practical planning. Pick a real situation where you supported the teammate without blaming them. Emphasise checking priorities, informing the supervisor early, redistributing work, adjusting scope if needed, and protecting quality. Interviewers listen for maturity, communication, teamwork, and willingness to take responsibility under pressure.

Showing 60 of 1,512 questions. Ranked by how often the same question came back across interviews.

Practise a Goldman Sachs-style interview

A spoken interview built from these questions, scored when you finish; the feedback is yours.

Start practising

When you are ready, record The One: a single interview hiring teams watch, so you stop repeating first rounds.

Common questions

What questions does Goldman Sachs ask?

Candidate interviews most often cover DSA (49%) and CS fundamentals (29%).

How many rounds does Goldman Sachs interview have?

Candidate interviews show an average of 4.3 rounds per experience, with a typical sequence of Online test → Technical → Technical → Technical. Individual interview paths can vary.

Is the Goldman Sachs interview hard?

Among questions with a recorded difficulty, the mix is easy 31%, medium 58%, hard 11%.