Goldman Sachs
40+ Ashish Interview Questions and Answers
Q1. Good old standard problem: Playing number game with your friend to select any of the number between 1 to 3. Whoever reaches 20 first, wins. You have to tell the strategy to win the game. Basically, you start wi...
read moreThe strategy is to always subtract the number chosen by the friend from 4 to ensure reaching 16 first.
Start with 20 and subtract the number chosen by the friend from 4.
Continue this strategy until reaching 16 before the friend reaches 17-19.
Ensure the friend ends up at any number between 17 to 19 before reaching 16.
Q2. Given a tank with liquid, and there are flows in and out, inflow is U and outflow is Kx, where x is current height of liquid in tank, all needed quantities given, what are the conditions for overflow and steady...
read moreConditions for overflow and steady state in a tank with inflow and outflow
Overflow occurs when the inflow rate is greater than the outflow rate
Steady state is achieved when the inflow rate equals the outflow rate
Overflow can be prevented by adjusting the inflow rate or increasing the outflow rate
Steady state can be maintained by balancing the inflow and outflow rates
You are given an array/list ARR consisting of N integers. Your task is to find the maximum possible sum of a non-empty subarray(contagious) of this array.
Note: An array C is a subarray of a...read more
Q4. Given we have a (un)biased die, with given probabilities, and we toss it till we get a sum of 100 or more (basically if the sum crosses 100), and we stop. What is the most probable number you will get on the la...
read moreThe most probable number on the last toss is 6.
The probability of getting a sum of 100 or more is highest when the sum is 99.
The last toss will be made to reach the sum of 100, so the most probable number is the one that will take the sum closest to 100.
The sum of 94 can be achieved by rolling a 6 on the last toss, which is the most probable number.
Design and implement a data structure for Least Recently Used (LRU) cache to support the following operations:
1. get(key) - Return the value of the key if the key exists in the cache, o...read more
You have been given a binary matrix of size 'N' * 'M' where each element is either 0 or 1. You are also given a source and a destination cell, both of them lie within the matrix....read more
Q7. Suppose a man starts at 0, and has to go to 20 on the number line. He can either move in steps of 1 or 2. How many number of ways can he do this? Extending this, if we know the number of ways for going from 0 t...
read moreCount number of ways to reach 20 on number line starting from 0 in steps of 1 or 2. Derive recursive formula for n+1.
Use dynamic programming to count number of ways for each step.
For each step, number of ways is sum of number of ways for previous 1 or 2 steps.
Recursive formula: ways[n+1] = ways[n] + ways[n-1]
Q8. There is an urn with n red balls and 1 black ball in it. You and your friend play a game where you take turns drawing from the urn. The player who draws the black ball first wins. Should you go first or second?
Go second. The probability of winning is higher when going second.
The probability of winning when going first is (1/n+1), while the probability of winning when going second is (n/n+1)
This is because the first player has a chance of drawing the black ball on their turn, while the second player has a chance of drawing the black ball on their turn or the first player's turn
For example, if there are 10 red balls and 1 black ball, the probability of winning when going first is 1/1...read more
Q9. Suppose there are N chocolates, and I pick a random one, and eat that chocolate and also everything to the right of it. I then continue this process with the remaining. How many ways are there to do this?
There are (N-1)! ways to eat chocolates from left to right.
The first chocolate can be chosen in N ways, the second in (N-1) ways, and so on.
However, since the order of chocolates eaten matters, we need to divide by the number of ways to order N chocolates, which is N!.
Therefore, the total number of ways to eat chocolates is (N-1)!
For example, if N=4, there are 3! = 6 ways to eat the chocolates.
Q10. Given 3 functions, f which gives the first day of the current month, g gives the next working day and h gives the previous working day, conpute the 3rd working day? Compute the 2nd working day of the previous m...
read moreCompute working days using given functions f, g, and h.
To compute the 3rd working day, apply function g three times to function f.
To compute the 2nd working day of the previous month, apply function h to function f, then apply function g twice.
To compute the 4th working day of the next month, apply function g four times to function f.
Q11. Suppose you and I are playing a dice game. The one who get the lesser number looses the games. The dice has n sides. If I start the game, what is the probablity of you winning?
Probability of winning a dice game where the one with lesser number wins.
The probability of winning depends on the number of sides on the dice.
If the dice has an odd number of sides, the probability of winning is higher for the second player.
If the dice has an even number of sides, the probability of winning is equal for both players.
Q12. There is a 2D plane with infinite parallel, vertical lines with a spacing of 1 unit between them. You drop a rod of length L randomly on the plane, with random position and orientation. What is the probability ...
read moreProbability of a randomly dropped rod of length L intersecting a line on a 2D plane with infinite parallel, vertical lines.
The probability depends on the length of the rod L.
The probability can be calculated using geometric probability.
The probability is 1 - (2L - 1) / infinity.
For example, if L = 1, the probability is 0.5.
If L = 2, the probability is 0.75.
Q13. Given a biased coin, how do you create an unbiased toss?
Flip the coin twice and consider the outcome as follows.
Flip the coin twice and consider the outcome as follows:
- If both flips are heads or both are tails, discard and flip again.
- If the first flip is heads and the second is tails, consider it as heads.
- If the first flip is tails and the second is heads, consider it as tails.
This method ensures a 50-50 chance of getting either heads or tails.
Alternatively, use a physical method to balance the weight distribution of the coi...read more
Q14. Given a number line, and we have a rod of length L. We drop the rod on the line, what is the probability that it covers an integer?
Probability of a rod of length L covering an integer on a number line.
The probability depends on the length of the rod and the distance between adjacent integers on the number line.
If the length of the rod is less than the distance between adjacent integers, the probability is zero.
If the length of the rod is greater than or equal to the distance between adjacent integers, the probability is (L - d)/d, where d is the distance between adjacent integers.
The probability can be c...read more
Q15. Supposed there is a party, with 9 people, each person wants to give gifts to 3 people and also wants a gift from them. Is this scenario possible? If not, when is this possible? Give me a general case
No, it is not possible for each person to give gifts to 3 people and receive a gift from them in a party of 9 people.
In this scenario, each person would need to receive 3 gifts, which is not possible if there are only 9 people.
This scenario would be possible if there were at least 10 people at the party.
In general, for a party of n people, each person can give gifts to n-1 people and receive gifts from n-1 people.
Q16. You have an n x n matrix in which all the rows and all the columns are sorted. Given an input number, describe an algorithm to search for the number in the matrix
Algorithm to search for a number in an n x n matrix with sorted rows and columns.
Start from the top-right corner of the matrix
If the current element is greater than the target, move left
If the current element is less than the target, move down
Repeat until the target is found or the bottom-left corner is reached
Q17. Is the price of a barrier option more or less than a normal option?
The price of a barrier option is generally less than a normal option.
Barrier options have a condition that must be met for the option to be activated, which reduces the likelihood of the option being exercised.
This reduced likelihood of exercise means that barrier options are generally cheaper than normal options.
However, the price of a barrier option can vary depending on the specific conditions and terms of the option.
For example, a knock-in barrier option may be more expen...read more
Q18. You roll a die until the sum of all die rolls becomes at least 100. What is the most likely value of the last roll?
What is the most likely value of the last roll in a game where a die is rolled until the sum of all rolls is at least 100?
The last roll must be at least 4 to reach a sum of 100
The probability of rolling a 4, 5, or 6 is 1/2
The most likely value of the last roll is 4 or 5
Q19. Given coordinates of some points, find a figure that encompasses all of the points. The figure should have the least possible area and be formed by joining points using straight lines. Convex Hull.
The Convex Hull is the smallest convex polygon that encloses all given points.
Sort the points based on their x-coordinate.
Find the upper hull by starting from the leftmost point and moving clockwise.
Find the lower hull by starting from the rightmost point and moving counterclockwise.
Combine the upper and lower hulls to form the convex hull.
Q20. If I have to buy fuel from you, what option would I buy?
You can buy fuel from us through our fuel card program.
We offer a fuel card program that allows you to purchase fuel from our network of stations.
Our fuel card program offers discounts and rewards for frequent users.
You can easily track your fuel expenses and usage through our online portal.
We also offer customized fuel solutions for businesses and fleets.
Our fuel is high-quality and meets all industry standards.
Q21. If we increase the volatility of the stock, how does the price of a call option change?
Increasing stock volatility increases the price of a call option.
Higher volatility means higher potential for the stock to move in the option holder's favor, increasing the option's value
The option's delta and gamma will also increase with higher volatility
Example: If a call option on a stock with a strike price of $50 has a premium of $2 when the stock has a volatility of 20%, increasing the volatility to 30% may increase the premium to $2.50 or higher
Q22. Find the magic number in an sorted array. magic number is the one whose value and index position is same
Find the magic number in a sorted array where value and index are same.
Iterate through the array and check if the value and index are same
If found, return the value
If not found, return -1
Q23. Clarification about what CPI stands(Is it the same as Grade Point Average?)
CPI stands for Consumer Price Index, not the same as Grade Point Average (GPA).
CPI is a measure of the average change over time in the prices paid by urban consumers for a market basket of consumer goods and services.
It is used to track inflation and price changes in the economy.
GPA, on the other hand, is a measure of academic performance and represents a student's average grade point across courses.
CPI and GPA are completely different concepts and have no relation to each ot...read more
Q24. What is the expected number of tosses of a fair coin to get 3 consecutive heads?
Expected number of tosses of a fair coin to get 3 consecutive heads.
The probability of getting 3 consecutive heads is 1/8
The expected number of tosses to get 3 consecutive heads is 14
This can be calculated using the formula E(X) = 2^k + 2^(k-1) + 2^(k-2) + ... + 2^2 + 2^1 + 2^0, where k is the number of consecutive heads required
Q25. What is a call option? Why are call options bought?
A call option is a financial contract that gives the buyer the right, but not the obligation, to buy an underlying asset at a predetermined price within a specified time period.
Call options are bought by investors who believe that the price of the underlying asset will rise in the future.
The buyer of a call option pays a premium to the seller for the right to buy the asset at a predetermined price, known as the strike price.
If the price of the asset rises above the strike pri...read more
Q26. How do you calculate the price of a call option?
The price of a call option is calculated using the Black-Scholes model which takes into account the underlying asset price, strike price, time to expiration, risk-free interest rate, and volatility.
Determine the current price of the underlying asset
Determine the strike price of the option
Determine the time to expiration of the option
Determine the risk-free interest rate
Determine the volatility of the underlying asset
Plug these values into the Black-Scholes model to calculate ...read more
Q27. Given two arrays of size n each, describe an algorithm to find the largest common subarray of the two arrays
Algorithm to find largest common subarray of two arrays of size n
Create a 2D array to store the lengths of common subarrays
Traverse both arrays and fill the 2D array with lengths of common subarrays
Find the maximum length and its corresponding ending index in the 2D array
Use the ending index to retrieve the largest common subarray from either of the arrays
Q28. Row sorted and column sorted matrix problem of finding an element.
The problem involves finding an element in a matrix that is sorted both row-wise and column-wise.
Start from the top-right corner of the matrix
Compare the target element with the current element
If the target is smaller, move left; if larger, move down
Repeat until the target is found or the matrix boundaries are crossed
Q29. Different efficient ways to implement product and summation of n numbers. And limitations
Efficient ways to implement product and summation of n numbers with limitations.
For summation, use a loop or built-in functions like sum() or reduce().
For product, use a loop or built-in functions like prod() or reduce().
Limitations include overflow errors for large numbers and memory constraints for very large arrays.
Using parallel processing or vectorization can improve efficiency.
Consider using data structures like binary trees or prefix sums for faster calculations.
Q30. If You have an infinite array then how many ways to sort it and also tell the complexities
There are infinite ways to sort an infinite array with varying complexities.
Sorting algorithms like QuickSort, MergeSort, HeapSort, etc. can be used to sort the array.
The time complexity of sorting algorithms varies from O(n log n) to O(n^2).
The space complexity also varies depending on the algorithm used.
Sorting an infinite array is not practical, so it is usually done in chunks or using parallel processing.
The sorting order can be ascending or descending based on the requir...read more
Q31. What do you know about options?
Options are financial contracts that give the buyer the right, but not the obligation, to buy or sell an underlying asset at a predetermined price.
Options can be used for hedging or speculation
There are two types of options: call options and put options
Call options give the buyer the right to buy the underlying asset at a predetermined price, while put options give the buyer the right to sell the underlying asset at a predetermined price
Options have expiration dates and strik...read more
Q32. A person can climb 1 or 2 stairs. Find the number of ways to jump n stairs
Number of ways to jump n stairs if a person can climb 1 or 2 stairs.
Use dynamic programming to solve the problem.
The number of ways to jump n stairs is equal to the sum of ways to jump n-1 stairs and ways to jump n-2 stairs.
Base cases: if n=0, return 1 and if n=1, return 1.
Q33. Given a 2d matrix sorted row and column wise, search an element
Searching an element in a sorted 2D matrix
Start from the top-right corner or bottom-left corner
Compare the target element with the current element
Move left or down if the target is smaller or move right or up if the target is larger
Q34. Efficient algorithms on calculating Fibonacci’s Sequence
Efficient algorithms for calculating Fibonacci's sequence
Use dynamic programming to avoid redundant calculations
Implement matrix exponentiation to reduce time complexity to O(log n)
Use memoization to store previously calculated values
Iterative approach using constant space complexity
Binet's formula for direct calculation of nth Fibonacci number
Q35. How will you mane a LRU Cache
An LRU cache can be made using a doubly linked list and a hash map.
Create a doubly linked list to store the cache items.
Create a hash map to store the key-value pairs.
When a new item is added, check if the cache is full. If it is, remove the least recently used item from the linked list and hash map.
When an item is accessed, move it to the front of the linked list.
When an item is removed, remove it from both the linked list and hash map.
Q36. Find integer solutions of x^y=y^x.
Find integer solutions of x^y=y^x.
If x=y, then x^y=y^x=1
If x
If x>y, then x^y>y^x
Only solution is (2,4) and (4,2)
Use logarithms to prove
Q37. difference between hedge funds and private equity
Hedge funds are actively managed investment funds that use various strategies to generate high returns, while private equity firms invest in private companies and aim to increase their value.
Hedge funds are open to a wider range of investors than private equity funds
Hedge funds use leverage to increase returns, while private equity firms use debt to finance acquisitions
Hedge funds have a shorter investment horizon than private equity firms
Private equity firms typically take a...read more
Q38. Design a newspaper subscription system
Design a newspaper subscription system
Create a user registration system
Allow users to select subscription plan and payment method
Provide options for delivery frequency and start/end dates
Send reminders for subscription renewal
Allow users to modify or cancel subscription
Track subscription history and payment records
Q39. Explain what is Binary Search Tree
Binary Search Tree is a data structure where each node has at most two children, with left child less than parent and right child greater.
Nodes have at most two children - left and right
Left child is less than parent, right child is greater
Allows for efficient searching, insertion, and deletion of elements
Q40. What is Asset Management
Asset management is the process of managing and optimizing a company's assets to maximize their value and minimize risk.
Asset management involves identifying, tracking, and evaluating assets
It includes developing strategies to optimize asset performance and minimize risk
Examples of assets that can be managed include financial investments, real estate, and equipment
Asset management can be done in-house or outsourced to a third-party firm
Q41. what is custodian banking
Custodian banking involves holding and safeguarding financial assets on behalf of clients.
Custodian banks provide services such as asset safekeeping, settlement of trades, and corporate actions processing.
They also offer reporting and analytics to clients on their holdings and transactions.
Examples of custodian banks include State Street, BNY Mellon, and J.P. Morgan.
Custodian banking is important for institutional investors such as pension funds, mutual funds, and hedge funds...read more
Q42. what is private equity
Private equity is a type of investment where funds are raised from investors to acquire or invest in companies that are not publicly traded.
Private equity firms typically buy a controlling stake in a company and then work to improve its operations and profitability before selling it for a profit.
Private equity investments are typically made in mature companies with a proven track record of success.
Private equity firms may also invest in distressed companies with the goal of t...read more
More about working at Goldman Sachs
Top HR Questions asked in Ashish
Interview Process at Ashish
Top Analyst Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month