## Goldman Sachs Interview Questions

- 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

- 0of 0 votes
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.

- 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
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

- 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
Find out the least recent occurred message.

Suppose your are getting message in streams, and you add it using add("M1").

You need to find out the least recent occurred message at any point of time.

for example,

Add("M1')->Add("M2') then LROM=M1

Add("M1')->Add("M2')->Add("M1') then LROM =M2

Add("M1')->Add("M2')->Add("M1')->Add("M3')-> then LROM =M2

Hope question is clear.

- 0of 0 votes
Create a random number generator within the given range? what if no range given? it should not repeat the sequence of random numbers generator before and after JVM is re-booted?

- 0of 0 votes
Create a random number generator within the given range or without range, it should repeat the sequence of random numbers generator before and after JVM is re-booted

- 0of 0 votes
Given an input string, write a function that returns the Run Length Encoded string for the input string.

For example, if the input string is “wwwwaaadexxxxxx”, then the function should return “w4a3dex6″.

- 0of 0 votes
Given a string .Check if the string is palindrome or not

- 1of 3 votes
A Multi-threaded server application stops working and the last log message from the application is:

`"Some Server Related Message..."`

Code looks like:

`CalledFunc () { Code ... Acquiring Thread lock Line printing "Some Server Related Message..." Func(); Releasing Thread Lock }`

1. What should the programmer in charge do to debug this?

2. What has happened wrong in the Func()?

3. If an exception is thrown in the Func() what should be done to fix problem ?

- 0of 0 votes
A Multi-threaded server application stops working and the last log message from the application is:

`"Some Server Related Message..."`

Code looks like:

`CalledFunc () { Code ... Acquiring Thread lock Line printing "Some Server Related Message..." Func(); Releasing Thread Lock }`

1. What should the programmer in charge do to debug this?

2. What has happened wrong in the Func() ?

3. If an exception is thrown in the Func() what should be done to fix problem ?

- 0of 0 votes
[Phone screen]

Let's say I gave you a long String and I wanted you to tell me the most common word in that String. How would you do that?

follow-up: OK, how would you estimate the size and time complexity of this solution? How would you estimate the ACTUAL size usage? (Hint: how many words are in the English language? Would having a dictionary in front of you help?)

follow-up #2: OK, how about if I gave you the entire works of Alexandre Dumas, one of the most prolific authors in history. How would your solution work? How could you change it to solve this more specific problem?

follow-up #3: Now, what if we wanted to find the most common PHRASE in his writings. (Upon clarification, the interviewer wouldn't give a specific length, so I clarified to finding as long as a common 10 word phrase, because anything longer is unlikely.)

- 0of 0 votes
[Phone screen]

Tell me about the Java Collections framework, what are its main interfaces. OK, what are the main differences between the Set and List interfaces? What do you give up if you go from a List to a Set, and what do you get in exchange for this if you go from a List to a Set? How would you go about guessing the order of an iteration() of HashSet if I told you I was going to insert the strings "first", "second", "third", "forth", and "fifth"?