Recently, Goldman Sachs conducted a set of tests in our college in order to select summer interns and I’ll try to note my experience in detail here to help others prepare 🙂
Round 1: The first round was an Online Test conducted on the Hackerrank platform. It consisted of 18 multiple choice questions-8 from general Computer Science topics like time complexity analysis, syntax check and formal language and 10 questions on statistics and probability. Scoring: +10 for each correct answer, -2 for wrong answers.
There was also one coding question of 20 marks. The question was as follows: We were given an array of strings which represented the names of cities and 2 more 1-D arrays which represented the x and y coordinates of the cities, in order (So city, x and y will have the complete information of the first city). Then we had to answer m queries where for each query we were given a city name and we had to return a city which either had x or y coordinate in common with the current city and had the shortest possible distance from that city. If multiple such cities existed, we had to return the lexicographically smallest one and in case no city had x or y common with the current city, we had to return “NONE”.
Constraints: n (Number of cities) and m (number of queries) Length of city name All cities would have unique coordinates.
I used a custom sorting approach and maintained 2 arrays (sort on basis of x-coordinate in one array and y-coordinate in the other, followed by lexicographical order) and then performed a binary search over the array to get the lexicographically smallest city. I had also used a Hashmap in order to quickly retrieve the city name from the coordinates.
12 people were selected for further rounds.
Round 2: The interviewer initially asked me to introduce myself for 5 minutes or so and then started asking me questions from my resume. I believe that since I had mentioned Java to be my primary language in my resume, the questions were primarily from that, some of which were:
- Explain the meaning of “public static void main (String args)” in a Java code. What happens if any of these keywords are omitted? Is there any workaround?
- Why doesn’t Java support multiple inheritance?
- Differentiate between JVM, JRE, and JDK.
- How to mimic the behavior of pointers using references in Java?
- What do you know about the garbage collector routines in the JVM?
- Explain multithreading in Java.
I was also asked basic questions on algorithms like:
- Find the lowest common ancestor in a Binary Search Tree (https://www.geeksforgeeks.org/lowest-common-ancestor-in-a-binary-search-tree/)
- Detect if a linked list has a loop (https://www.geeksforgeeks.org/detect-loop-in-a-linked-list/)
- Maximize profit by buying and selling a stock only once (https://www.geeksforgeeks.org/stock-buy-sell/?utm_source=tuicool)
He ended the interview by again asking me basic questions like “Do you have any idea of how Goldman Sachs operates?”, “If you were to choose between Goldman Sachs and Microsoft, which one would you choose? Why?” and finally, the most predictable one, “Do you have any questions for me?”
6 people were selected for the final round.
Round 3: This round was fast-paced and revolved around algorithms and puzzles (well, a lot of puzzles). Some of them involved:
- Implement a stack using queues.
- Check if the binary representation of a decimal number is a palindrome.
- Given a set of k balls (number of each ball being n1, n2…nk), count the number of ways to arrange them on a number line such that they follow a given sequence (For example, if n=3 and the sequence is GYB, the last green ball must come before the last yellow ball which in turn must come before the last blue ball )
- Implement large factorial calculation without the help of any libraries such as BigInteger in Java.
- A discussion on relative efficiency and usage of trees versus maps.
Puzzles/probability: Well, I was extremely glad to have practiced the puzzles archive of GeeksForGeeks as the questions were mostly familiar to me (:P)
- Camel and banana puzzle (https://www.geeksforgeeks.org/puzzle-15-camel-and-banana-puzzle/)
- Know average salary without disclosing individual salaries (https://www.geeksforgeeks.org/puzzle-26-know-average-salary-without-disclosing-individual-salaries/)
- Finding the fastest 3 horses (https://www.geeksforgeeks.org/puzzle-9-find-the-fastest-3-horses/)
- If a random number of ants are walking on a stick of 1 m length and if after a collision between 2 ants they instantly reverse their velocities, what is the minimum time in which all ants are guaranteed to fall off the table? The ants can be anywhere on the stick initially and can choose any direction to move. (Answer: 1 second)
- If a single juror has a probability p of making the correct decision and there is a 3 person jury where 2 jurors have the same probability p and the third has probability 1/2 of making a correct decision, which is better? Does your answer depend on the value of p? (Answer: Both are equivalent)
The trick is to keep your calm and let the interviewer know what you are thinking in case you are stuck as he/she will definitely help you out!
Finally, two people were selected from our college for the internship, one of which was me.