# Goldman Sachs Interview Experience | September 2019 | Experienced

Improve

I had 2 years of experience when I got a call from Goldman about hiring going on for a certain team. There were 6 rounds in total (2 online + 4 onsite).
There is a system in our college where students can log in 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, the admin can query this database the next day. Queries can be like find the most frequent search requests (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. The interviewer was satisfied with the approach.
We had 10 minutes remaining. The second interviewer gave a question – There is a number x. We can do a query twice where the first 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 task is to find x.
The approach was to keep in mind that XOR of a number with itself is 0. If we do XOR of n with the given set, we will get x somewhere (y will be canceled) in the first list. Similarly, we will get x in the 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 the interviewer seemed satisfied.

### Please

**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:- Merge adjacent elements of an array based on certain conditions until that condition was getting satisfied. Then, the output was to print the final set of elements in the array.

**Round 2:**Coderpad I could see that C++ was available for coding. But Java was finalized as the language of coding after discussion with the interviewer.- Given two fractions which are represented as an array of two elements (numerator and denominator), the task to find the reduced fraction which is the sum of two fractions.
- Given two sorted arrays, find the median of them.

**Round 3**Onsite- The question was modification of this Find the first circular tour that visits all petrol pumps. The additional condition here was to make sure that petrol utilization was minimum.

**Round 4:**Onsite- 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 a winner between them (assuming two teams do not play more than once). I approached this problem using a directed graph. We can build a directed graph using the tournament data. If we can find a path between T1 to T2, T1 is the winner. If the same happens for T2 to T1, T2 is the winner. If no path is found, then data is inadequate. The approach had to be optimized for the huge number of queries (10^5). I used a hashmap to store graph data (adjacency matrix/list) which would be optimal during query.
- Given a string that 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 it again. It is important to note that the 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**Round 6:**OnsiteÂ One of the interviewers appeared to me as a manager. I was asked to explain my current work in layman terms. Then, there was one DS problem – Find a pair that has the sum closest of a given number X. I coded and explained my approach which involved two pointers. The 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. The 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 another 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. The interview ended with some general discussion. HR informed me that my feedback was positive.Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Share your thoughts in the comments