## Goldman Sachs Interview Questions

- 1of 1 vote
You have given height array of array. Generate the original array.

Input: [6,3,0,2,2,0,0]

Output : [ 1,5,7,3,2,6,4]

A[i] value in input array is the number of greater element on right side.

- 0of 0 votes
How to print nested array ?

Input : [1, 5, 8, [9, 10, 24, 20, [39, 48], 89], 105, 99]

Output : 1, 5, 8, 9, 10, 24, 20, 39, 48, 89, 105, 99.

Which data structure you will use to store the values?

- 0of 0 votes
Given two sorted linked lists, how can you combine them into one big sorted list? Do not create additional nodes.

- 0of 0 votes
There is going to be a sale during this month. You are interested in a particular item and you found that different Vendors have different prices during different time periods. You collected the following information:

`Vendor => (start date, end date, price) both sides inclusive A => (1, 5, $20) B => (3, 6, $15) C => (2, 8, $25) D => (7, 12, $18) E => (1, 31, $22)`

As you can see, there are conflicting entries. You need to print out a non-conflicting schedule of prices, taking the best price from each period:

e.g.

(1, 2, $20), (3, 6, $15), (7, 12, $18), (13, 31, $22)

- 0of 0 votes
Given a list of currency exchange rates like this:

EUR/USD => 1.2

USD/GBP => 0.75

GBP/AUD => 1.7

AUD/JPY => 90

GBP/JPY => 150

JPY/INR => 0.6

write a method`double convert(String sourceCurrency, double amount, String destCurrency);`

For example, convert(EUR, 100, INR)

The method should minimize the number of intermediate conversions.

- 0of 0 votes
Given two sorted integer arrays, find the median element. Note that for an even sized collection, median element is to be defined as the average of the central two elements.

- 2of 2 votes
Singleton Design pattern. How you make it double ton(in even call of getInstance() first object should be return and odd call of getInstance() second instance should be return). Make it triple ton.

- 1of 1 vote
Print series 010203040506. Using multi-threading 1st thread will print only 0 2nd thread will print only even numbers and 3rd thread print only odd numbers.

- 0of 0 votes
Given a remote having 0-9 digits, plus button (to increase channel), minus (to decrease) and previous channel button (to go to previous channel). We were given 2 numbers stating start and end channel number and an array having various channel numbers. The task was to go to all channel numbers given in array with minimum number of clicks.

- 2of 2 votes
I was given a questions during an interview which I was not able to solve, please help me in finding the solution.

Ques : - Divide the set in two partition such that both the partition has minimum difference of their sum. If we add an element to the left subset during partitioning than the value of that number will automatically increases by 1, but it will not increase by 1 if I add it to the right side. Find the minimum difference between both the subsets : -`ex :- {1,2,3,4,5} leftSubset = {3,4} , rightSubset = {1,2,5} effective sum of leftSubset = 3+4+2(number of elements) effective sum of rightSubset = 1+2+5 = 8 difference of left and right = (9-8)=1 =, min difference`

solution : (1,2,3} {4,5}

- 0of 0 votes
Jamie is walking along a number line that starts at point 0 and ends at point n. She can move either one step to the left or one step to the right of her current location , with the exception that she cannot move left from point 0 or right from point n. In other words, if Jamie is standing at point i,she can move to either i-1 or i+1 as long as her destination exists in the inclusive range [0,n]. She has a string ,s , of movement instruction consisting of the letters 1 and r , where 1 is an instruction to move one step left and r is an instruction to move one step right.

Jamie followed the instructions in s one by one and in order .For Example if s=‘rrlr’,she performs the following sequence of moves :one step right ->one step right ->one step left -> one step right .Jamie wants to move from point x to point y following some subsequence of string s instruction and wonders how many distinct possible subsequence of string s will get her from point x to point y. recall that a subsequence of a string is obtained by deleting zero or more characters from string .

it has four parameters

A String , s giving a sequence of eduction using the characters l( i.e. move left one unit ) and r (i.e. move right one unit)

An integer n, denoting the length of the number line.

An integer x, denoting jamie’s starting point on the number line

An integer y , denoting Jamie’s enidng point on the number line.

The function must return an integer denoting the total number of distinct subsequence of string s that will lead Jamie from point x to point y as this value cab be quite large .

Sample Input

rrlrlr

6

1

2

out put =7

- 1of 1 vote
Write a Java program to get the count of ipv6 address present in the provided address range.

Ex: if we provide ipv6 address range 2001:db8::/124 then the program should display the range contains 16 IP's.Starting from 2001:db8:: to 2001:db8:0000:0000:0000:0000:0000:000f.

- 0of 0 votes
We tend to use computer to solve practical problems that actually earns or save dollars. Here is something that happens across the stock exchanges : people buy and sell stocks.

We generally use automated intelligent systems to buy and sell stocks. That part is too much mathematics, and beyond scope of this interview. There is another part. Suppose the system issues a buy order : buy 1000 Microsoft stock. Now, there are more than 1 ( in fact 10 ) active exchanges from where we can buy MSFT. There is a slight price delta, which keeps changing over time. There is another problem. In each stock exchange, prices are stacked, that is :

1. For first 100 stocks prices are 55$.

2. Next 200 stocks, prices are 55.2$.

... etc, and you got the idea. Even this stacks are changing over time.

Thus, here is the problem to solve. Design and implement a system such that one can buy n stocks with minimal price.

Also, in the same spirit, the same system should be able to sell n stocks with maximum payoff possible.

This is a non trivial problem, for Quant systems.

There are always k no of exchanges to hit.

- 1of 1 vote
Algorithm to minimize number of trassaction.

Eg:

A->B = Rs. 5

B->C = Rs. 8

C->D = Rs. 9

A->D = Rs. 10

D->B = Rs. 11

C->A = Rs. 12

Minimize transactions.

- 0of 0 votes
Algorithm to minimize number of trassaction.

Eg:

A->B = Rs. 5

B->C = Rs. 8

C->D = Rs. 9

A->D = Rs. 10

D->B = Rs. 11

C->A = Rs. 12

Minimize transactions.

- 0of 0 votes
Given a histogram chart with values say {5,4,3,6,0,1}. Get the total count required to completely melt the histogram. A column with value 5 has 5 blocks in it. Any block which has air on any of its side gets melted.

Sample 1

{5,4,3,6,0,1} - > {0,3,2,0,0,0}->{0,0,0,0,0,0} => count=2

Sample 2

{0,1,1,1,1,0} - > {0,0,0,0,0,0} => count=1

- 0of 0 votes
What is Static class in Java? What is singleton class? How are they different.

- 0of 0 votes
Is java pass by value or pass by reference?

Then he asked various question related to this.

What if i pass integer, array list or object will the change reflect in the original function.

In case of object will we have different behavior when i set it to null in the called function or when I call its method(setName("") for example ).

- 1of 1 vote
You toss a fair coin 400 times. What’s the probability that you get at least 220 heads? Round your answer to the nearest per cent.

- 0of 0 votes
in one string array{'Good',''word','good','woRd'...}

how can i print like Good--2

Word-2 times appeared in the array.even Good and good are different in case sensitive.

- 0of 2 votes
IN phone directory,i have like below details

ABc---123

bcd--345

cda--523

abc--678.

So if i want to see Abc person phone numbers we should get the both the numbers,how can we implement this in java

- 2of 2 votes
You have String array like{'cat','good','tac','act''....} like some 1000 words.

So if i give input tac ,output should be cat and act..

How can we implement with less complexity

- 0of 0 votes
We have rectangular and inside many rectangular were drawn.So if we click on main Rectangular we should get the count of rectangular's ..For this how can we implement in java

- 0of 0 votes
We have a Very big which our datatypes does not provide.

We need to multiply such numbers, how to do?

example :

Num1 = {1,2}, Num2 = {1,0} then ans would be {1,2,0}

Num1 ={5,3,6,2,8,2,0,2,8}, num2 ={3,5,2,3,2,1,}

then ans would be the multiplication value of 5362882028 X 352321

- 0of 0 votes
You to find the shortest palindrome string by adding 0 or more characters on the right side of the string.

for example:

string is java then answer would be avajava

string is enm then mnemn

string is aavaa then aavaa

- 0of 0 votes
How to implement your own Hashmap?

- 0of 0 votes
You have infinite number of 3Rs coins and 5Rs coins. And your are provided one random number and u need to find out that whether you can make the amount with both denominations.

for example:

U r given a number: 23 then 5*4 +3 = 23 so true

U r given a number :16 then False.

- 0of 0 votes
You have a string and you need to find the shortest palindrome string from that string by adding 0 or more characters on right side of the string.

example:

String is java then answer would be avajava

String is emme then emme

String is hcasach

- 0of 0 votes
How to implement your own HashMap??

How to handle the collision using some chaining technique?

- 0of 0 votes
We have a Very big which our datatypes does not provide.

We need to multiply such numbers, how to do?

example :

Num1 = {1,2}, Num2 = {1,0} then ans would be {1,2,0}

Num1 ={5,3,6,2,8,2,0,2,8}, num2 ={3,5,2,3,2,1,}

then ans would be the multiplication value of 5362882028 X 352321