## Goldman Sachs Interview Questions

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

- 1of 1 vote
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.

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

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