Goldman Sachs Interview Experience | Experienced

I got a call from Goldman about hiring going on for certain team. There were 6 rounds in total (2 online + 4 onsite).

Round 1 – Hackerrank

There were 2 questions which you can attempt at home. Since the preferred language was Java/Python, I used Java to solve them. I do not remember the questions exactly. I somewhat remember the second question. The question was to merge adjacent elements of an array based on certain condition till that condition was getting satisfied. Then, output was to print the final set of elements in the array.

I got a call from HR after a week to finalize the date for coderpad round. HR asked me to confirm if I was proficient in Java/Python or not. I mentioned that I know Core Java but I would to use C++ for coding as it is easy to code using it. She told me to discuss this with interviewer. The finalized date was one week after the call.

Round 2 – Coderpad

I could see that C++ was available for coding. But Java was finalized as language of coding after discussion with interviewer.

Q1. Given two fractions which are represented as an array of two elements (numerator and denominator), the task to find the reduced fraction which is sum of two fractions.

This is an easy mathematical problem which will also involve GCD. I discussed the approach and coded it in 5-10 minutes. I missed the corner case of negative numbers. I put validation for the same and then moved on to next question.

Q2. Given two sorted arrays, find the median of them.

This is a standard problem but I was not aware of the fastest approach. I could think of an approach where I was making sure that elements are shuffled in a way that both of them are sorted and last element of left array is less than or equal to first element of right array. I discussed the approach which he understood and then I started to code. I had almost finished the coding when time got over. He said that code could be optimized but he understood my approach.

I could then think of O(n) approach which involves merging of two sorted arrays where we do not merge actually and just have to keep count of middle element. There is another approach which is O(logn) and involves comparing median of two sorted arrays. Date of onsite round was kept after two weeks.

Round 3 – Onsite

The question was modification of this problem. The additional condition here was to make sure that petrol utilization was minimum.

It was difficult for me to think about optimal approach in the beginning. I then suggested brute force approach where at any point we can choose to pick or not pick the pump. We can choose the best one out of it. Then after some discussion, I got a hint after which I could think of an approach involving heap (priority queue). I was asked to code this approach. Question was then modified again to add a condition that at any pump, we cannot pick more than x amount of petrol. I did some conditional change to my approach but could not think of any other optimization.

Second interviewer checked my resume and he wanted to ask some questions related to JS. I mentioned that I was not comfortable in the same and he could ask me JAVA. He said it was okay and he was done. But the first interviewer asked me questions related to HashMap, its implementation (load factor and other topics), worst case of get operation, implementation of heaps etc.

Round 4 – Onsite

Q1. Given a set of pairs which represent a game between two teams in a tournament and corresponding winner of each pair, find the result of a query where we give two teams and we have to find winner between them (assuming two teams do not play more than once).

I approached this problem using directed graph. We can build a directed graph using the tournament data. If we can find a path between T1 to T2, T1 is winner. If same happens for T2 to T1, T2 is winner. If no path is found, then data is inadequate.

The approach had to be optimized for huge number of queries (10^5). I used a hashmap to store graph data (adjacency matrix/list) which would be optimal during query.

Q2. Given a string which can contain special characters, the task was to find if string formed using characters (ignoring special ones) is a palindrome.

I wrote the code in 10 minutes. I missed one case in my code. I rechecked and then submitted again. It is important to note that code must be production grade (bug free). Even if we code fast, accuracy is an important concern. Take 5 extra minutes but think of all edge cases.

Round 5 – Onsite

Q1. There is a system in our college where students can login using student id, open browser and do a search. Each search will be stored in a database with data as – student id, search request and timestamp. After collecting all search requests in a day, admin can query this database next day. Queries can be like find most frequent search request (in general and for a student) and similar.

We need to design two methods – store and query. The task here is to make sure that we think of an approach to make these methods faster. We can do trade-offs (query can be given more importance than storage in this case – this was not specified explicitly).

I used hashmap and heap to solve the problem. Interviewer was satisfied with the approach.

Q2. We had 10 minutes remaining. Second interviewer gave a question – There is a number x. We can do a query twice where each query will give n = x ^ y (XOR) where y is a number out of 100 randomly picked numbers. In the next query(say) similarly, we pick 100 numbers randomly and then return m = x ^ z (XOR) where z belongs to set of random numbers.

The approach was to keep in mind that XOR of a number with itself is 0. If we do XOR of n with given set, we will get x somewhere (y will be cancelled) in first list. Similarly, we will get x in second list. Search for similarity of a number in two lists (assuming uniqueness) will give x. I could solve this problem in 5 minutes fortunately and interviewer seemed satisfied.

Round 6 – Onsite 

One of the interviewers appeared to me as manager. I was asked to explain my current work in layman terms. Then, there was one DS problem – Find a pair which has sum closest of a given number X. I coded and explained my approach which involved two pointers.

Next question was related to DB (joins). I approached the problem but could not find a simplified query. I explained that this would be simple to solve in ABAP (language used in my current project). But they said it would not be of any use as they are not aware of the same.

Last question was a puzzle. Given 3 trains which start at the same time and place and we can transfer fuel from one train to other such that limit does not exceed given X (for all trains), find the maximum distance covered by any of the trains. I was able to think of approach after a hint. We can transfer fuel from one train to other after 1/3 interval. This can be generalized to 1/n for n trains. The resultant distance will be a harmonic progression. Interview ended with some general discussion.

HR informed me that my feedback was positive.

Write your Interview Experience or mail it to

My Personal Notes arrow_drop_up

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.