## Goldman Sachs Interview Questions

- 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

- 1of 1 vote
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"?

- 1of 1 vote
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
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"?

- 0of 0 votes
[Phone screen]

Tell me what you know about the java.lang.Object class. OK, what are best practices for the equals method? How would you implement an equals method for a class with 100s of data fields?