Goldman Sachs interview experience Real time questions & tips from candidates to crack your interview

SDE - 1

Goldman Sachs
upvote
share-icon
4 rounds | 11 Coding problems

Interview preparation journey

expand-icon
Preparation
Tip
Tip
Application process
Where: Campus
Eligibility:
Resume Tip
Resume tip

Interview rounds

01
Round
Easy
Face to Face
Duration
Interview date9 Sep 2019
Coding problem3

This was face to face interview round. Interviewer was very friendly. He started by asking tell me something about yourself. I told him about my interest in competitive coding(since I am weak in probability, I always mentioned about competitive coding in my introduction so that the interviewer asks me coding questions and didn’t move to probability section).

1. Minimize the maximum difference between the heights

Ninja
44m average time
50% success
0/200
Asked in companies
OYOFacebookGoldman Sachs

Given heights of n towers and a value k. We need to either increase or decrease height of every tower by k (only once) where k > 0. The task is to minimize the difference between the heights of the longest and the shortest tower after modifications, and output this difference.

 

Examples:

 

Input  : arr[] = {1, 15, 10}, k = 6

Output :  Maximum difference is 5.

Explanation : We change 1 to 6, 15 to  

9 and 10 to 4. Maximum difference is 5

(between 4 and 9). We can't get a lower

difference.

 

Input : arr[] = {1, 5, 15, 10}  

       k = 3    

Output : Maximum difference is 8

arr[] = {4, 8, 12, 7}

 

Input : arr[] = {4, 6}  

       k = 10

Output : Maximum difference is 2

arr[] = {14, 16} OR {-6, -4}

 

Input : arr[] = {6, 10}  

       k = 3

Output : Maximum difference is 2

arr[] = {9, 7}  

 

Input : arr[] = {1, 10, 14, 14, 14, 15}

       k = 6  

Output: Maximum difference is 5

arr[] = {7, 4, 8, 8, 8, 9}  

 

Input : arr[] = {1, 2, 3}

       k = 2  

Output: Maximum difference is 2

arr[] = {3, 4, 5}

Problem approach
  • At first, I didn’t got any approach in my mind but then I gave interviewer a completely brute force solution but the interviewer was not satisfied. Then I thought to do something with sorting but after making lot of efforts I still couldn’t give approach to the interviewer and he moved to next question. Also I was little bit nervous at that time.
Try solving now

2. Minimum Number of Platforms Required for a Railway/Bus Station

Easy
23m average time
85% success
0/40
Asked in companies
IBMBarclaysThought Works

Given arrival and departure times of all trains that reach a railway station, the task is to find the minimum number of platforms required for the railway station so that no train waits.

We are given two arrays which represent arrival and departure times of trains that stop.

 

Examples:

 

Input: arr[] = {9:00, 9:40, 9:50, 11:00, 15:00, 18:00}

dep[] = {9:10, 12:00, 11:20, 11:30, 19:00, 20:00}

Output: 3

Explantion: There are at-most three trains at a time (time between 11:00 to 11:20)

 

Input: arr[] = {9:00, 9:40}

dep[] = {9:10, 12:00}

Output: 1

Problem approach
  • Firstly I pretended that I am seeing this question for the first time. Then told him the sorting based solution after few minutes of thinking. I simply sort the both arrival time and departure time array and found the minimum number of platforms.
Try solving now

3. Two and Four Wheeler Roads

Hard
48m average time
0/120
Asked in companies
CognizantGoldman SachsFlipkart

Given cities and roads connecting them. Roads are of three types: type 1-> 2 wheelers road, type 2 -> 4-wheelers road and type 3-> both 2 and 4 wheelers road. The problem was to find the max number of roads that can be removed s.t a path exists for every pair of cities for each 2 wheelers and 4 wheelers.

Problem approach

KI simply gave him brute force approach for this question and he was quite satisfied with that.

 

Try solving now
02
Round
Easy
Face to Face
Duration30-40 minutes
Interview date9 Sep 2019
Coding problem3

1.

An archer is hitting the target(a circle). He fires the first shot and then second shot. GIven that his shot was better than the second. Find the probability that the third shot that he fires is best among the three. The three shots are independent of each other.

Problem approach
  • This was probability based question and I am weak in that. I thought of various approaches like Bayes, intersection etc but could not find answer to this question.

2. Stock Buy Sell to Maximize Profit

Moderate
20m average time
80% success
0/80
Asked in companies
PayPalGrabNatwest Group

The cost of a stock on each day is given in an array, find the max profit that you can make by buying and selling in those days. For example, if the given array is {100, 180, 260, 310, 40, 535, 695}, the maximum profit can earned by buying on day 0, selling on day 3. Again buy on day 4 and sell on day 6. If the given array of prices is sorted in decreasing order, then profit cannot be earned at all.

Problem approach
  • This was the standard question and I solved it using local minima and local maxima concept and wrote code for the interviewer and he was satisfied with my code as well as approach.
Try solving now

3. Find Minimum Depth of a Binary Tree

Moderate
20m average time
80% success
0/80
Asked in companies
MakeMyTripSliceAcko

Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.

For example, minimum height of below Binary Tree is 2.

Example Tree

 

 

Problem approach
  • I firstly gave him recursion approach then he asked me to optimize it in case of skew tree, then I gave him level order traversal based approach and he was happy with that approach.
Try solving now
03
Round
Easy
Face to Face
Duration
Interview date9 Sep 2019
Coding problem3

1.

System Design: Design a job scheduler. Tasks will be given as inputs with an extra parameter ‘delay’ meaning that task has to run after this ‘delay’ time.

Problem approach
  • I gave him solution using multithreading with proper explanation. My communication with interviewer was very good so he got my solution very easily.

2. Gas Station

Moderate
20m average time
90% success
0/80
Asked in companies
GoogleCognizantGoldman Sachs

Given two integer arrays A and B of size N.

There are N gas stations along a circular route, where the amount of gas at station i is A[i].

 

You have a car with an unlimited gas tank and it costs B[i] of gas to travel from station i

to its next station (i+1). You begin the journey with an empty tank at one of the gas stations.

 

Return the minimum starting gas station’s index if you can travel around the circuit once, otherwise return -1.

 

You can only travel in one direction. i to i+1, i+2, … n-1, 0, 1, 2.. Completing the circuit means starting at i and

ending up at i again.

 

 

 

Input Format

 

The first argument given is the integer array A.

The second argument given is the integer array B.

Output Format

 

Return the minimum starting gas station's index if you can travel around the circuit once, otherwise return -1.

For Example

 

Input 1:

   A =  [1, 2]

   B =  [2, 1]

Output 1:

   1

Problem approach
  • Again this question was already done by me before the interview and for few minutes I was pretending that I was thinking then I gave him O(n) solution which was similiar to concept of Kadane Algorithm with minor changes according to the question.
Try solving now

3. Arithmetic Progression Queries

Ninja
44m average time
50% success
0/200
Asked in companies
OYOFacebookGoldman Sachs

 Normal segment tree with update operation on [l, r] and some constant value x  s.t add add x to a[l], x+1 to a[l+1], ……., x+r-l to a[r]. Normal range query i.e calculate the sum in [l, r].

Problem approach

I thought lot about this question with lazy propagation and mad optimizations in that according to question but could not solve this question as few minutes were given to me for this question.

Try solving now
04
Round
Easy
Face to Face
Duration
Interview date9 Sep 2019
Coding problem2

1.

 Given a point on the perimeter of the circle and an interior point. Find the probability that the rectangle formed with diagonal as the line segment joining these points lies inside the circle.

Problem approach
  • At first I could not get any approach and then I asked for hint and then I solved this question by dividing circle in two semicircles and considering the cases for point and finding probability in each case and integrating them.

2. Married Couples at a Party

My wife and I recently attended a party at which there were four other married couples. Various handshakes took place. No one shook hands with oneself, nor with one's spouse, and no one shook hands with the same person more than once. After all the handshakes were over, I asked each person, including my wife, how many hands he (or she) had shaken. To my surprise each gave a different answer. How many hands did my wife shake?

Problem approach
  • This was very high level puzzle and I almost took 10 minutes to think this at the time of interview. The answer was 1 which I found out considering the pairs and making cases. After this, I found out that the married couples shook hands in pairs 8th person shook hand with 0, 7th  with1, 6th with 2, 5th with 3. The only person left who shook hands with 4 is the wife and hence answer was one.

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

What is a constructor in Java?

Choose another skill to practice
Start a Discussion
Similar interview experiences
company logo
SDE - 1
2 rounds | 4 problems
Interviewed by Goldman Sachs
1219 views
0 comments
0 upvotes
company logo
SDE - 1
1 rounds | 3 problems
Interviewed by Goldman Sachs
886 views
0 comments
0 upvotes
company logo
SDE - 1
3 rounds | 5 problems
Interviewed by Goldman Sachs
1320 views
0 comments
0 upvotes
company logo
SDE - 1
5 rounds | 12 problems
Interviewed by Goldman Sachs
212 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
5 rounds | 12 problems
Interviewed by Amazon
106202 views
24 comments
0 upvotes
company logo
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
50846 views
5 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Amazon
31613 views
6 comments
0 upvotes