Skip to content
Related Articles
Open in App
Not now

Related Articles

Goldman Sachs Interview Experience | Set 19

Improve Article
Save Article
  • Difficulty Level : Medium
  • Last Updated : 28 May, 2019
Improve Article
Save Article

I had an interview with GS at their Bengaluru office. I have 4 years of experience in full stack development using Java. I had got a call from a consultant.

  • Round 1

    1. What concepts are u comfortable within Java? I said collections. He asked which collection classes have u used? I said HashMap, ArrayList and HashSet.
    2. When would u use Set and when a list? I said Set supports unique non-null elements and List does not have that constraint. So, if I want unique elements, I will use Set. He asked any other consideration? I said the type of queries to be performed on the collection. Like search. He asked any example? I said – employees database. Employees must be unique, so we can use List and search by binary search or a similar technique, as generally, they are sorted in some order. But I think he had been expecting the O(1) lookup time answer or Set. I explained the working of HashMap and HashSet and how that would help a developer to easily achieve the uniqueness of elements but the interviewer was not convinced with my answer to his original question.
    3. What is the contract of equals() and hashCode()? What if one is overridden but the other is not?
    4. Find second minimum in a given array.
    5. Find the pivot point in a sorted and rotated array.
    6. Any question for me?
  • Round 2

    1. Give a brief introduction about ur work experience.
    2. Give an overview of your recent project’s design.
    3. Suppose I have a UI where there is a list or table of items and each item has a profit attribute, a discount attribute, etc. How to ensure that multiple users do not leave the state of any item inconsistent. User can update the attributes or some other web service can do the same. I suggested synchronizing the setter methods of the item. He asked how to sort the items. I said the items would reside in an array list and implemented the Comparable interface. He asked for a working code. When I wrote the expression inside the compareTo() method, he said that the design is not flexible as there exists hard coding of sort criteria. He said that when someone wants to sort by another attribute, it would become impossible to manage so many duplicate objects. I said we can do it with the Factory Method Pattern. At this, he effectively terminated the interview round. Somewhere in between, he had mentioned the Comparator interface and I explained to him how it works. I said it is a good choice if one does not want to modify the existing classes. I think he was expecting the compare() method’s implementation, as that would not require duplicate objects and the sort by different criteria can be done by simply implementing Comparator in different classes, one class for each sort criterion, and then invoking the sort() method of the Collections class with that Comparator implementation.
    4. Any question for me?

    Was told to leave for the day. Advice: Try not bringing up design patterns unless asked to do so or u have experience in solving problems with design patterns. Listen to the interviewer and be alert. They provide hints. In round 1 too, I had done a mistake in the rotated array question. He gave a test case where my code would fail. I corrected the pitfall. Take enough sleep before the day of the interview.

    This article is contributed by Anonymous. 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

    My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!