GeeksforGeeks App
Open App
Browser
Continue

# Goldman Sachs Interview Experience | 1 year experienced

The recruiter contacted me over LinkedIn, and sent me the link for the written test.

Round 1

1. There is a shop with old-style cash registers. the price of each item is typed manually. Given a list of items and their correct prices, compare the prices to those entered when each item was sold. Determine the number of errors in selling price.

E.g.

```Input:
products = ['eggs','milk','cheese']
productPrices = [2.89,3.29,5.79]
productsSold = ['eggs','eggs','milk','cheese']
sellingPrices = [2.89,2.99,3.29,5.97]
Output: errors = 2
```
2. Remove all consecutive duplicates from the string

1. Given a log file as some array of strings in a specified format where each line begins with an IP address. You have to find the most frequently occurring IP.

2. Given a 2-D String array of student-marks find the student with the highest average and output his average score. If the average is in decimals, floor it down to the nearest integer.

E.g.

```Input:  [{"Bob","87"}, {"Mike", "35"},
{"Bob", "52"}, {"Jason","35"},
{"Mike", "55"}, {"Jessica", "99"}]
Output: 99
```

Basic questions on HashMap working, as both the above question solutions, I did use HashMap.

Round 3 (Technical): Taken by 2 senior members having 6-8 years exp. working with GS.

1. Given a custom HashMap, in which only equals() method was overridden, he made small changes in the code, and I was expected to give the number of entries in HashMap after each change.
2. Asked the internal working of HashMap in detail.
3. When the new objects are created by JVM?
4. Minimum steps to reach the target by a Knight
5. Stock Buy Sell to Maximize Profit
6. A code was given that has the method and variable overriding implemented in it with all possible scenarios, and I was expected to give the output in all possible scenarios. (If you have a complete understanding of how overriding works in java, you can answer them).
7. How overriding works for methods and variables?
8. What are immutable classes?

Round 4 (Technical): Taken by 2 senior members with 10-12 years exp working with GS.

1. Discussed project and the technologies used, based on resume.
2. String class and where they are stored in memory.
3. Additions in java 8 in interfaces (about default keyword), and diamond problem, and how it is resolved when default keyword is used.
4. How HashMap works, and the contract it follows.
5. What are immutable classes, I was asked to implement a custom immutable class? When I implemented it, multiple cross-questions were asked, to check if I have a clear understanding of each part of the code, I wrote or not.
6. Singleton Class, I started from a very basic form of Singleton Class and was asked in each implementation if there is some way in which I can break the Singleton Pattern. Then I wrote the code with double-check locking in singleton class.
7. Volatile Keyword, and how it works.
8. They were trying to ask about reflection API in java, but I did not hear of it before, so I clearly told them and they just skipped it.
9. Sum of all the numbers that are formed from root to leaf paths
10. Difference between Exception and Error, Checked and Unchecked Exception.
11. DIfference between Final keyword and Immutable classes.
12. Static keyword.
13. How JVM takes memory back from objects.

Round 5 (Technical): Taken by 2 senior members with 10-12 years exp working with GS.

1. What is minheap?
2. Given numbers [1,2,3,4,5], they are inserted in any order in an array, Tell the probability that the array is a minheap.
3. Find any local minima in the array. I told the O(n) approach, and then they asked to optimize it.
4. I need to write the complete code for this question and was expected to tell any solution that comes to my mind: Given 4 rectangular coordinates in a 2-D plane, and the millions of points, I need to tell the points that lie inside the rectangle. I told the brute force approach first, then they asked to give something more optimal, then I started approaching it using Binary Search, interviewer gave a lot of hints as he wanted the question to be finished fast, and then asked me to write the code for it.
5. Again the HashMap question, and its contract, which objects are safe to be used in hashmap. (Seemed like HashMap was their favourite, I was asked in each round).

Round 6 (Hiring Manager):