# 10 coding problems you could see in a Goldman Sachs interview

When preparing for any interview in software engineering, you need to be practicing byÂ solving problems on Leetcode. Not only is it a way of keeping your mind sharp, but many of the problems seen there are repurposed by banks as questions for their software developer interviews.

Struggling to figure out which ones to go for? These are 10 Leetcode problems that Goldman Sachs have used in their interviews in the past.Â

### 1. Maximum Good People Based on Statements

**Difficulty: Hard**

**Submissions: 22.4k**

**Success rate: 49.2%**

Much like this puzzle separates people into "good" and "bad", this difficult question will create a disparity between those who can solve it and those who can't.

Good people always tell the truth, bad people sometimes lie and sometimes tell the truth. You are given a series of statements by these people where they will call another person either good or bad and you must calculate the maximum possible number of good people.Â

This is the first example they give:

Â

You can see the top voted solution here.

### 2.Â Count Nice Pairs in an Array

**Difficulty: Medium**

**Submissions: 56.1k**

**Success Rate: 42.1%**

A decidedly simpler and less conceptual problem, this question will give you an array of numbers and pick out two from it. These two numbers (i and j) will be a 'nice' pair if:

`0 <= i < j < nums.length`

`nums[i] + rev(nums[j]) == nums[j] + rev(nums[i])`

The goal of the problem is to figure out how many possible 'nice' pairs there are in a given array.

Seems simple enough, right? Don't get too ahead of yourself, one leetcode user says "never underestimate two sums..."

You can see the top voted solution here.

### 3.Â Get Biggest Three Rhombus Sums in a Grid

**Difficulty: Medium**

**Submissions: 26.2k**

**Success rate: 47.1%**

This geometric problem may be listed under the medium difficulty but based on responses, it might be a lot harder.Â

One user asks "why is this question under Medium Category?" while another says that if an interviewer ever asks him this question, he "would run the opposite direction. I don't wanna work with this kind of people." It has nearly three times as many dislikes as it does likes.

The problem itself involves calculating the sum of each square contributing to a rhombus on a square grid and displaying only the three highest values. This is one of their examples:Â

Yes, those red and green squares have rhombi with an area of zero. So the three values here would be 8, 9 and 20 (the sum of the four squares that make up the blue rhombus.

In the top voted solution, the author said, "I was thinking that we need some clever implementation here, but I did not see it." They instead opted for a brute force approach.

You can see that solution here.

### 4.Â All Elements in Two Binary Search Trees

**Difficulty: Medium**

**Submissions: 232.7k**

**Success Rate: 79.8%**

A decidedly more popular and well like question than the one above, All Elements in Two Binary Search Trees is exactly what it says on the tin. It asks you to return all integers in a set of trees tree in ascending order.Â

Here is an example of one set:

In this example the numbers should be returned as: 0, 1, 1, 2, 3, 4.

You can see the top voted solution here.

### 5.Â Invalid Transactions

**Difficulty: Medium**

**Submissions: 191.9k**

**Success Rate: 31.2%**

Another wildly unpopular question you'd be fortunate to avoid, Invalid Transactions has over 4.5 times as many dislikes as it does likes.Â

One recent response says "This would've been a good DS problem if the description wasn't written by a 5 year old."

A transaction given could be invalid if the price exceeds $1000 or occurs within 60 minutes of another transaction featuring the same name in a different city.

It seems as though even the popular solutions have little time for this problem either, the most voted one says their solution was "what I got in the shortest time and get accepted..."

You can see that solution here.

### 6.Â Number of People Aware of a Secret

**Difficulty: Medium**

**Submissions: 37.1k**

**Success Rate: 44.9%**

Another more conceptual problem, it's no secret (wink) that this problem could come up in your interview.

After a single person discovers a secret, they tell a new person each day. They go on to tell more people the secret but there is a chance that people will also forget the secret.

The goal 7 the problem is to figure out how many people know the secret after a given number of days.

You can see the top voted solution here.

### 7.Â IPO

**Difficulty: Hard**

**Submissions: 180.9k**

**Success Rate: 49.7%**

A problem directly related to the world of finance? Time to really strut your stuff as a developer.

There's some contention as to how difficult the problem actually is. One response says "this problem should downgrade to medium" while a more recent one says "a moment of silence to whoever got this in an interview."

The challenge comes from maximizing resources; you have only a certain number of tasks you can complete before the IPO launches and you must choose the correct set that results in the highest possible final capital.

You can see the top voted solution here.

### 8.Â Maximum Points in an Archery Competition

**Difficulty: Medium**

**Submissions: 24.9k**

**Success Rate: 49.5%**

You'll have to stay on targetÂ đźŽŻÂ to stand out when solving this problem.

Two archers, Alice and Bob, are in an archery competition. With 11 possible targets earning scores of ascending value from 1 to 11, whoever lands the most arrows in a given target earns that number of points

(landing multiple arrows in the same target does not mean they will earn that score multiplied by the number of arrows)

When given a scoreboard like below, the goal is to calculate the maximum number of points Bob can score in a round.

You can see the top voted solution here.

### 9.Â Count Good Triplets in an Array

**Difficulty: Hard**

**Submissions: 15.1k**

**Success rate: 38.7%**

While other problems with low acceptance rates seem to be thoroughly disliked or picked apart for their flaws, Count Good Triplets in an Array seems well liked, which implies it will certainly challenge coders and like up to that 'hard' tag.

You are given two arrays of numbers. You must discover each possible triplet (three numbers organized in ascending order within an array), then look for which triplets are seen in both arrays, thus making them a 'good' triplet and display that.

The problem may be light on the description, but that doesn't make it any less complicated. The top voted solution explains how it works with an extensive number of diagrams.

You can see that solution here.

### 10.Â Minimum Consecutive Cards to Pick Up

One of the few problems here with a pass rate above 50%, this is a problem you'd be at a disadvantage not to know.

That being said, it doesn't seem expressly diffiicult, one recent response says "this one should be marked as easy."

The premise itself involves drawing cards until you find a pair; the pair does not have to be drawn one after the other. The problem is calculating how many consecutive cards will be drawn, when given the array of their values, until a pair is found.

You can see the solution here.

**Have a confidential story, tip, or comment youâ€™d like to share? Contact:Â alex.mcmurray@efinancialcareers.comÂ in the first instance.Â **

*Bear with us if you leave a comment at the bottom of this article: all our comments are moderated by human beings. Sometimes these humans might be asleep, or away from their desks, so it may take a while for your comment to appear. Eventually it will â€“ unless itâ€™s offensive or libelous (in which case it wonâ€™t.)*