Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding
Ninjas X Naukri.com

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

Goldman Sachs

5 rounds | 8 Coding
problems

Journey

Before applying for this role, I was working at Expedia and Arcesium as a software developer. I worked for many years in both the companies and I got to learn alot by working there as a software developer. As soon as I saw a job opening for Goldmann Sachs, I started preparing DSA again. I went through previous interview experiences and started giving mock interviews so as to master coding skills once again.

Application story

I saw a job opening on the company's website. I reached out to a lot of people on LinkedIn for referral. One of the employees agreed to give me referral. So, I applied through his referral and then they called me for the interview rounds. The interviews went on smoothly and I got selected.

Why selected/rejected for the role?

I was selected because of my never-give up attitude. I had a different way of approaching questions. I understood the question properly first and then thought of a solution for the question. In this manner, I gave the answers clearly and confidently.

Preparation

Duration: 6 Months

Topics: Data Structures, Algorithms, Database, System Design, Operating Systems

Tip

Practice DP based questions as much as you can. Also, be confident during the interview about your solution. For practice, you can prefer Coding Ninjas and Geeks For Geeks.

Application process

Where: Referral

Eligibility:

Resume tip

Keep it short. Mention the academic and professional projects you've done. Add your educational details properly with percentage or CGPA obtained.

01

Round

Easy

Telephonic

Duration60 minutes

Interview date29 Apr 2019

Coding problem1

The interviewer called my via phone and simultaneously provided me a link where I had to write the code for a given problem. It was scheduled at 12:30 pm, so timing was not an issue. It was a standard DP question involving a 2D matrix. The question was easy and I was able to code it within given time.

Given a cost matrix cost[][] and a position (m, n) in cost[][], write a function that returns cost of minimum cost path to reach (m, n) from (0, 0). Each cell of the matrix represents a cost to traverse through that cell. Total cost of a path to reach (m, n) is sum of all the costs on that path (including both source and destination). You can only traverse down, right and diagonally lower cells from a given cell, i.e., from a given cell (i, j), cells (i+1, j), (i, j+1) and (i+1, j+1) can be traversed. You may assume that all costs are positive integers.

For example, what is the minimum cost path to (2, 2)?

The path with minimum cost is highlighted in the following figure. The path is (0, 0) â€“> (0, 1) â€“> (1, 2) â€“> (2, 2). The cost of the path is 8 (1 + 2 + 2 + 3).

Problem approach

- I had practiced enough of DP questions, so this one looked fairly easy. Since it was a standard DP question, the same approach worked here too.

02

Round

Easy

Face to Face

Duration60 minutes

Interview date5 May 2019

Coding problem2

The interviewer asked me two coding questions in this round.

Write an efficient program to find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum.

Problem approach

- I used Kadane algorithm here to find subarray with maximum sum. It is a standard question for interview.

Given a decimal number as N, the task is to convert N into an equivalent irreducible fraction.

An irreducible fraction is a fraction in which numerator and denominator are co-primes i.e., they have no other common divisor other than 1.

Examples:

Input: N = 4.50

Output: 9/2

Explanation:

9/2 in decimal is written as 4.5

Input: N = 0.75

Output: 3/4

Explanation:

3/4 in decimal is written as 0.75

Problem approach

- I was unable to solve this question in given time. I thought of using decimal precision and other things but not able to solve this.

03

Round

Easy

Face to Face

Duration60 minutes

Interview date20 May 2019

Coding problem2

This was on-site round at their Bangalore office. The interviewer was friendly and helpful. The interview held inside a conference room.

Given an integer N as input, the task is to print the Magical Pattern as given below:

N . . 3 2 1 2 3 . . N

. . . . . . . . . . .

3 3 3 3 2 1 2 3 3 3 3

2 2 2 2 2 1 2 2 2 2 2

1 1 1 1 1 1 1 1 1 1 1

2 2 2 2 2 1 2 2 2 2 2

3 3 3 3 2 1 2 3 3 3 3

. . . . . . . . . . .

N . . 3 2 1 2 3 . . N

Examples:

Input: 3

Output:

3 2 1 2 3

2 2 1 2 2

1 1 1 1 1

2 2 1 2 2

3 2 1 2 3

Input: 4

Output:

4 3 2 1 2 3 4

3 3 2 1 2 3 3

2 2 2 1 2 2 2

1 1 1 1 1 1 1

2 2 2 1 2 2 2

3 3 2 1 2 3 3

4 3 2 1 2 3 4

Problem approach

- I simply use for and while loops with some conditions and printed the required pattern.

```
V is the number of vertices present in graph G and vertices are numbered from 0 to V-1.
E is the number of edges present in graph G.
```

```
The Graph may not be connected i.e there may exist multiple components in a graph.
```

Problem approach

- As I have to find a number of connected components in an undirected graph so I simply use
**Depth-first search**to solve this question by visiting each element and mapped it to the number of component in which it belongs. At last, I print the vertices of each component.

04

Round

Easy

Face to Face

Duration60 minutes

Interview date20 May 2019

Coding problem2

This was the next round of the onsite interviews. Took place in the same conference room as that of the previous round.

Given a node, how long will it take to burn a whole binary tree?

Problem approach

- This was a completely different question for me. I had not seen this question before, but by drawing various cases on paper, I could write down the solution at the end. Also, I struggled a lot during this question but did not give up. I kept thinking out loud in order to at least explain my thought process to the interviewer, if not arrive at the right solution.

Given an array A[] consisting of N integers, the task is to find the total number of subsequence which contain only one distinct number repeated throughout the subsequence.

Examples:

Input: A[] = {1, 2, 1, 5, 2}

Output: 7

Explanation:

Subsequences {1}, {2}, {1}, {5}, {2}, {1, 1} and {2, 2} satisfy the required conditions.

Input: A[] = {5, 4, 4, 5, 10, 4}

Output: 11

Explanation:

Subsequences {5}, {4}, {4}, {5}, {10}, {4}, {5, 5}, {4, 4}, {4, 4}, {4, 4} and {4, 4, 4} satisfy the required conditions.

Problem approach

- For this question, I simply used some mathematics and considered the frequency of each element and their contribution to subsequences. Wrote its fully commented code with neat handwriting.

05

Round

Easy

Face to Face

Duration60 minutes

Interview date20 May 2019

Coding problem1

This was the third round of the onsite interview.

Given two strings str1 and str2 and below operations that can performed on str1. Find minimum number of edits (operations) required to convert â€˜str1â€™ into â€˜str2â€™.

Insert

Remove

Replace

All of the above operations are of equal cost.

Input: str1 = "geek", str2 = "gesek"

Output: 1

We can convert str1 into str2 by inserting a 's'.

Input: str1 = "cat", str2 = "cut"

Output: 1

We can convert str1 into str2 by replacing 'a' with 'u'.

Input: str1 = "sunday", str2 = "saturday"

Output: 3

Last three and first characters are same. We basically

need to convert "un" to "atur". This can be done using

below three operations.

Replace 'n' with 'r', insert t, insert a.

Problem approach

- Firstly I gave the interviewer, a recursive solution then he asked me to reduce complexity as it was exponential of recursive solution so I gave him a top-down DP solution.

Here's your problem of the day

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

What is the index number of the last element of an array with 9 elements?

Choose another skill to practice

Join the Discussion

7 replies

Load more comments

Similar interview experiences

SDE - 1

2 rounds | 4 problems

Interviewed by Goldman Sachs

1155 views

0 comments

0 upvotes

SDE - 1

1 rounds | 3 problems

Interviewed by Goldman Sachs

841 views

0 comments

0 upvotes

SDE - 1

3 rounds | 5 problems

Interviewed by Goldman Sachs

1229 views

0 comments

0 upvotes

SDE - 1

5 rounds | 12 problems

Interviewed by Goldman Sachs

144 views

0 comments

0 upvotes

Companies with similar interview experiences

SDE - 1

5 rounds | 12 problems

Interviewed by Amazon

105287 views

24 comments

0 upvotes

SDE - 1

4 rounds | 5 problems

Interviewed by Microsoft

50189 views

5 comments

0 upvotes

SDE - 1

3 rounds | 7 problems

Interviewed by Amazon

31267 views

6 comments

0 upvotes

This Comment was removed by the moderator

This comment won't show up to you, as it was removed by moderator due to inappropriate content.