Goldman Sachs
300+ Sahrudaya Healthcare (Medicover Hospitals) Interview Questions and Answers
You have been given a long type array/list 'ARR' of size 'N'. It represents an elevation map wherein 'ARR[i]' denotes the elevation of the 'ith' bar. Print the total amount of rainwater that ...read more
You are given a string S which represents a number. You have to find the smallest number strictly greater than the given number which contains the same set of digits as of the original number...read more
Q103. 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
Q104. 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
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 ...read more
You are given a string of length N representing the morse code(s). You have to convert this code into the corresponding alphanumeric code containing small case english alphabet[a-z] and di...read more
You have been given a binary tree with an integer value associated to each node. You are supposed to choose a subset of these nodes such ...read more
You have been given a binary tree of integers with N number of nodes. Your task is to check if that input tree is a BST (Binary Search Tree) or not.
A binary search tree (BST) is a binary tree data ...read more
You are given an array of strings 'ARRSTR[]' of size 'N' and a character 'C'. Your task is to sort the 'ARRSTR[]' according to the new alphabetical order that starts with the given characte...read more
You are given an N-ary tree where every node has at most ‘N’ child nodes. You need to first serialize it and then deserialize the serialized tree.
Serialization is the pro...read more
Design a data structure that stores a mapping of a key to a given value and supports the following operations in constant time.
1. INSERT(key, value): Inserts an integer value to the data...read more
Q112. How many years will it take the Delhi Metro to break even?
The Delhi Metro is expected to break even in 2025.
The Delhi Metro has been expanding rapidly and has seen a steady increase in ridership.
The metro has been able to generate revenue through advertising and property development.
The government has also provided financial support to the metro.
Based on current projections, the Delhi Metro is expected to break even in 2025.
Q113. Dice rolled several times until sum of outcomes till now comes greater than equal to hundred. What is most likely number to occur as final sum?
The most likely number to occur as the final sum is 100.
The sum of the outcomes of the dice rolls will keep increasing until it reaches or exceeds 100.
Since the dice have equal probabilities for each outcome, the sum will have a higher chance of reaching 100.
The probability of rolling a sum greater than 100 decreases as the sum gets larger.
You have been given a Binary Tree of integers. You are supposed to return the level order traversal of the given tree.
For example:
For the given binary tree
The level order traversal wil...read more
You are given N number of intervals, where each interval contains two integers denoting the start time and the end time for the interval.
The task is to merge all the overlapping intervals and re...read more
Ninja is planning to build a new apartment but he wants an apartment in the shape of a rectangle whose length is greater than the breadth of the rectangle. Also, the difference between the leng...read more
You are given two arbitrary binary trees consisting of N and M number of nodes respectively, your task is to check whether the two trees are mirror of each other or not.
Two trees a...read more
You are given an array of N integers and an integer K. For each array element, you are allowed to increase or decrease it by a value k. The task is to minimize the difference between the max...read more
Given an integer array(ARR) of size N, the following operations need to be performed:
update(l, r, val) : Add (val + i) to arr[l + i] where, 0 <= i <= r - l. rangeSum(l, r): return...read more
Q120. 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
Q121. Why are gold prices increasing and why are US treasury bonds still valuable?
Gold prices are increasing due to economic uncertainty and inflation concerns. US treasury bonds remain valuable due to their safe-haven status and reliable returns.
Gold prices are increasing due to economic uncertainty and inflation concerns.
Investors often turn to gold as a safe-haven asset during times of market volatility.
The demand for gold is also influenced by factors such as geopolitical tensions and central bank policies.
US treasury bonds are still valuable because t...read more
You are given a string STR representing the column title in an Excel Sheet. You need to find its corresponding column number.
For example: A corresponds to 1, B to 2, C to 3, … , Z to 26, AA...read more
You are given the arrival and departure times of N trains at a railway station in a day. You need to find the minimum of platforms required for the railway station such that no ...read more
Q124. How many airplanes are flying in the Indian sky at the moment?
The exact number of airplanes flying in the Indian sky at the moment is not available.
The number of airplanes flying in the Indian sky changes constantly.
It depends on factors such as time of day, weather conditions, and airline schedules.
However, on average, there are around 2,000 flights in the Indian airspace at any given time.
This number includes both domestic and international flights.
The Indian aviation industry has been growing rapidly in recent years, with more and mo...read more
You have been given an array 'ARR' of 'N' distinct elements.
Your task is to find the minimum no. of swaps required to sort the array.
For example:
For the given...read more
You are given a directed graph consisting of 'V' vertices and 'E' edges. You need to find whether a vertex i is reachable from all other vertices j for all pairs of vertices ...read more
You are given a multi-level linked list of N nodes, each node has a next and child pointer which may or may not point to a separate node. Flatten the multi-level linked list i...read more
There is a country with 'N' cities and 'M' bidirectional roads of 3 types.
Type 1: Two Wheeler Road, It means only vehicles having two wheels can use this road. Type 2: Four Wheeler R...read more
You are given a path to a file/directory in Unix-style of length N, In a Unix-style file system, a dot(.) refers to the current directory. A double dot(..) refers to the previous directory...read more
You are given a starting position for a rat which is stuck in a maze at an initial point (0, 0) (the maze can be thought of as a 2-dimensional plane). The maze would be given in the form of a squar...read more
You are given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list’s ‘HEAD.’
The fi...read more
You are given an arbitrary grid with M rows and N columns. You have to print the total number of rectangles which can be formed using the rows and columns of this grid. In simple w...read more
Q133. Cutting three random points on the circle of radius 1 centered at (0,0) . What is probability that point (1,0) lies in longest cut
Finding probability of point (1,0) lying in longest cut of three random points on circle of radius 1 centered at (0,0)
The longest cut will be the one that spans the smallest angle between two of the three points
The probability can be found by calculating the area of the region where the longest cut includes point (1,0)
This can be done by finding the angle between (1,0) and the two other points and using trigonometry to calculate the area of the corresponding sector of the cir...read more
Q134. 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
There is a group of people and a special person in the group who does not know anybody, while other people in the group know him. Given a function: find(A, B) -> which returns True if A knows B and...read more
You are given a sentence 'TEXT'. Each word of 'TEXT' is separated by a single space and the first letter of 'TEXT' is capital. You need to rearrange the words of Text in increasing ...read more
You are given a matrix ‘ARR’ having dimensions ‘N*M’. Your task to find the rank of the matrix ‘ARR’.
The rank of a matrix is defined as:
(a) The maximum number of linearly independent column vectors i...read more
Given an undirected graph, find how many triangles it can have where a triangle is a cyclic path of length three which begins and end at the same vertex.
#### An undire...read more
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 ...read more
Q140. 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
Write an efficient program to find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum.
1. There are 5 lanes on a race track. One needs to find out the 3 fastest horses among total of 25. Find out the minimum number of races to be conducted in order to determine the fastest three.
Q143. How many ways can a king go from one end of the chessboard to the diagonally opposite square(The king can move only towards the corner and not diagonally)
The king can move only towards the corner and not diagonally. How many ways can a king go from one end of the chessboard to the diagonally opposite square?
The king can only move towards the corner, so there are limited options for each move
The total number of moves required to reach the opposite corner is 14
Using combinatorics, the total number of ways the king can reach the opposite corner is 3432
Q145. Design Problem: You have a database of million records, that needs to be acessed for each operation. That database is updated very rarely. And there are multiple processes that queries the database and operates...
read moreImplement a caching mechanism to optimize database access for multiple processes.
Implement a caching layer to store frequently accessed records in memory
Use a cache eviction policy to remove least recently used records from the cache
Update the cache whenever the database is updated
Consider using a distributed cache if the processes are running on different machines
Q146. How to create a uniform distribution from 1 to 200 using an ubiased coin?
To create a uniform distribution from 1 to 200 using an unbiased coin, we can use the rejection sampling method.
Divide the range into equal parts based on the number of outcomes of the coin toss.
Toss the coin and select the corresponding part of the range.
If the selected number is outside the desired range, reject it and repeat the process.
Repeat until a number within the desired range is obtained.
Example: If the coin has 2 outcomes, divide the range into 2 parts of 100 each....read more
Q147. An IT sector company wants to increase the number of BPOs in India. Devise a metric that will help it rank cities according to their favourability to host this BPO
A metric to rank Indian cities for BPOs
Consider factors like availability of skilled workforce, infrastructure, cost of living, and government policies
Weight each factor based on its importance to the company
Collect data on each factor for different cities and assign scores
Rank cities based on their total score
Examples of factors: number of universities, quality of transportation, cost of office space, tax incentives
Regularly update the metric to reflect changes in the busine...read more
Q148. 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
Q149. Variants of using random number generators/Monte Carlo Simulations to generate value of Pi and other quantities
Random number generators and Monte Carlo simulations can be used to estimate the value of Pi and other quantities.
Monte Carlo simulations involve generating random numbers to estimate a value or solve a problem
To estimate Pi, random points are generated within a square and the ratio of points inside a circle to total points is used
Other quantities can be estimated using similar principles, such as estimating the area under a curve or the value of an integral
There is a city with bad roads. You have to repair the roads. How will you find the roads which are in bad condition? What parameters you will take to check if the road is in good condition? How will ...read more
Q151. Design a game (Automaton) for a betting scenario. Bet is either doubled or lost completely depending on whether you win or lose. Suppose you bet on team A constantly in a 2 team game, how much money you need in...
read moreQ152. Puzzle: You have two train carriages situated at a different point on a infinite train track. The carriage can move up and down , and given that they can only know whether the other train has started from this ...
read moreQ153. 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
Q154. What do you understand in KYC, KYC documents? In your previous organisation what did you learn? Can you tel something about what solution have you solve and what are the outcomes? Questions based on process imp...
read moreKYC refers to the process of verifying the identity of customers and assessing their potential risks.
KYC stands for Know Your Customer
KYC documents include identity proof, address proof, and other relevant documents
In my previous organization, I learned about the importance of verifying customer identities to prevent fraud and financial crimes
I have implemented process improvements to streamline the KYC process and reduce turnaround time
The outcomes of these solutions were im...read more
Q155. Design problem: You have a socket connection on client side. And that socket connection receives million ticks per second for every stocks. Suppose you have 50 stocks. So the value of each stock is changing 10,...
read moreQ156. 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.
Q157. Given a matrix containing several positive numbers find max path from bottom left to top right using only up and right steps
Find max path from bottom left to top right in a matrix using only up and right steps.
Start from bottom left corner and move towards top right corner.
At each step, choose the maximum value between the cell above and the cell to the right.
Keep track of the sum of values in the chosen path.
The final sum is the maximum possible sum of values in a path from bottom left to top right.
Q158. 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
Q159. You have a rod of length 7 and you have to give a part of rod of length of one everyday to a person. so what is the minimum number of cuts you will do , so that you can give him required number of lengths every...
read moreThe minimum number of cuts required is 6.
To give a part of rod of length one everyday, we need to divide the rod into 7 equal parts.
Each cut will create two new lengths, so we need 6 cuts to obtain 7 equal parts.
The cuts can be made at any point along the rod, as long as the resulting lengths are equal.
Q160. What is one key ratio you would look at for upstream companies ? (reserve replacement ratio for oil & gas)
The reserve replacement ratio is a key ratio to evaluate the ability of upstream companies to replace the reserves they produce.
The reserve replacement ratio compares the amount of reserves added to the amount of reserves produced in a given period.
A ratio above 100% indicates that the company is replacing more reserves than it is producing.
A ratio below 100% indicates that the company is producing more reserves than it is replacing.
The reserve replacement ratio is important ...read more
Q161. 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
Q162. How would you design an elevator system for a building?
Designing an elevator system for a building involves considering factors like capacity, speed, safety, and efficiency.
Determine the number of floors and the expected traffic flow in the building
Calculate the required capacity and speed of the elevators
Consider safety features such as emergency stop buttons, fire-resistant materials, and backup power supply
Implement efficient algorithms for elevator scheduling to minimize waiting time
Incorporate user-friendly features like cle...read more
There are 3 ants sitting on three corners of a triangle. All ants randomly pick a direction and start moving along the edge of the triangle. What is the probability that any two ants collide?
a person has 3000 bananas and a camel. He wants to transport the maximum number of bananas to a destination which is 1000 KMs away Camel eats 1 banana for every km. What is the maximum number of bananas t...read more
Basic questions related to speed time distance, profit-loss, prime factors, etc
Q166. 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.
Q167. How would you code a linked list? Show the code
A linked list is a data structure where each element contains a reference to the next element.
Create a Node class with data and next pointer
Create a LinkedList class with head pointer
Implement methods like insert, delete, search, etc.
Q168. 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
Q169. 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
You have been given a column title as appears in an Excel sheet, return its corresponding column number.
For example:
A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ...
Input Format
The only lin...read more
You have been given a column title as appears in an Excel sheet, return its corresponding column number.
For example:
A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ...
Input Format
The ...read more
An archer is hitting the target(a circle). He fires the first shot and then the second shot. Given that his
shot was better than the second. Find the probability that the third shot that h...read more
Q174. Puzzle: there are two candles and each candle take 30 minutes to burn. How will you measure 45 minutes? You dont have any instruments with you
Q175. What is the probability of a 8 bit string to have no more than 2 consecutive 1's. This might seem like a probability question :p. But it is actually dynamic programming.
Probability of an 8 bit string with no more than 2 consecutive 1's using dynamic programming.
Use dynamic programming to calculate the probability of a string with no more than 2 consecutive 1's
Create a 2D array to store the probabilities of each bit position and number of consecutive 1's
Use recurrence relation to calculate the probability for each bit position based on the previous bit position
Sum up the probabilities for all possible combinations of the last bit position and...read more
Given a node, how long will it take to burn a whole binary tree?
Q177. You are given ROE for 2 IT companies? how would you find out which is undervalued & overvalued?
Compare ROE of 2 IT companies to determine undervalued and overvalued.
Calculate the average ROE for the industry to use as a benchmark
Compare the ROE of the two companies to the industry average
Consider other factors such as growth potential, debt levels, and market share
Use valuation methods such as P/E ratio and discounted cash flow analysis
Undervalued company will have lower ROE than industry average and lower valuation metrics
Overvalued company will have higher ROE than i...read more
There is a room with a door (closed) and three light bulbs. Outside the room, there are three switches, connected to the bulbs. You may manipulate the switches as you wish, but once you open the door you ...read more
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...read more
Q180. What is the difference between OOP and procedural programming?
OOP focuses on objects and their interactions, while procedural programming focuses on procedures and functions.
OOP organizes code into objects that encapsulate data and behavior.
Procedural programming uses functions to manipulate data.
OOP supports concepts like inheritance, polymorphism, and encapsulation.
Procedural programming is more straightforward and linear in nature.
OOP promotes code reusability and modularity.
Procedural programming is often used for small-scale projec...read more
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.
I mentioned front-end web developer internship in my resume, so he asked me which data structures I have used in frontend web development
Q183. randN function : which generates random number in [1,2,3..N] with equal probability. Given rand5, write a code for rand7 using rand5
Code for rand7 using rand5 function
Use rand5 twice to generate a number in [1,25] with equal probability
If the number is greater than 21, discard and try again
Otherwise, return (number mod 7) + 1
What is the difference between SQL and NoSQL databases?
How does the variable declaration and the corresponding data type allotment done in Javascript?
Q185. what is virtual memory? Will we need virtual memory even if we have infinite amount of RAM?
Virtual memory is a memory management technique that allows a computer to use more memory than it physically has.
Virtual memory uses a combination of RAM and hard disk space to store data.
It allows programs to use more memory than is physically available.
If a program tries to access memory that is not currently in RAM, it will be swapped in from the hard disk.
Even if we had infinite RAM, virtual memory would still be necessary for certain tasks such as memory isolation and pr...read more
What are Semaphores? Explain in detail
Implementing the LRU Cache and its uses
What is deadlock and how you can prevent it?
What is difference between process and thread?
Explain critical section.
Q189. Given an array, Find out maximum length of subarray where max of subarray <= 2*min of subarray
Find maximum length of subarray where max <= 2*min.
Iterate through array and keep track of max and min values.
Update max length when condition is met.
Time complexity: O(n)
What is virtual Memory ?
what are ACID properties ?
Difference between Overriding and Overloading ?
Q191. Write code for implementing Tower of Hanoi problem. What data structures you will use? How will you implement the Move function(that moves the disc)
Tower of Hanoi is a mathematical puzzle that involves moving a stack of disks from one peg to another peg.
Tower of Hanoi problem involves three pegs and a number of disks of different sizes.
The goal is to move all the disks from the source peg to the destination peg, using the auxiliary peg.
The Move function can be implemented recursively by following the steps:
1. Move n-1 disks from source to auxiliary peg.
2. Move the nth disk from source to destination peg.
3. Move the n-1 d...read more
Q192. What is chargeback and explain the chargeback cycle?
Chargeback is a transaction reversal made by a bank or credit card issuer, usually due to fraud or disputed charges.
Chargeback occurs when a customer disputes a charge and the bank or credit card issuer reverses the transaction.
The merchant is notified of the chargeback and can either accept it or dispute it.
If the chargeback is accepted, the merchant loses the sale and may be charged a fee.
If the chargeback is disputed, the bank or credit card issuer investigates and makes a...read more
He asked me to do a system design for a website like Instagram which can be used by travellers.
Q194. Write an algorithm which will make the train carriages meet. The same algorithm should run on both the carriages
Algorithm to make train carriages meet
Use a two-pointer approach
Start with two pointers at opposite ends of the array
Move the pointers towards each other until they meet
Q195. Given a list of numbers give an algorithm that to find 2 numbers that add up to 600. He asked me to improve the complexity with every attempt I made finally got it down to complexity of O(N)
Algorithm to find 2 numbers that add up to 600 from a list of numbers with O(N) complexity.
Use a hash table to store the difference between each number and 600.
Iterate through the list and check if the difference is in the hash table.
If the difference is in the hash table, return the current number and the difference.
What language do you code in ?
Situational Problem
Q198. you have been given a tree(not binary tree), and the last level of the tree is doubly linked list(i.e. first node of that level connected to last node and adjacent to it and similarly for all nodes of that leve...
read moreQ199. N door puzzle. ith user changes state of doors which are multiples of i. Calculate number of doors opened in the end
Q200. Fiscal Deficit crowds out private investment – True or False. Why?
True. Fiscal deficit leads to higher interest rates, reducing private investment.
Fiscal deficit leads to higher government borrowing, increasing demand for credit
Higher demand for credit leads to higher interest rates
Higher interest rates make borrowing expensive for private investors
Expensive borrowing reduces private investment
Examples: India's fiscal deficit led to high interest rates, reducing private investment in 2013-14
More about working at Goldman Sachs
Top HR Questions asked in Sahrudaya Healthcare (Medicover Hospitals)
Interview Process at Sahrudaya Healthcare (Medicover Hospitals)
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month