 # How was your Goldman Sachs exam?

The first two questions are quite easy, but the third one is hard for me.
I really dont know what to in advance problem there.

2 Likes

Dynamic programming !!!

3 Likes

I’m struggling to improve dP, though if u know any similar problem on CC or cf please link it.

2 Likes

Could you please explain how you solved that problem ? The goldmann sachs question .

Is you familiar with this If not please look at that once . Amazing collection of some most important questions on DP .

1 Like

When did it happen ? who could have applied for the exam ? Did you manage to pass entire test set?

@robin
what is the formula for getting no of ways of subsets in second program?

its formula is nCr, n=primesum+k-1 and r=k-1

4 Likes
``````int minimizeMeetingCost(int N, int M, vector<vector<int>>& costs) {

vector<vector<int>> up(N,vector<int>(M,0));
vector<vector<int>> down=up,left=up,right=up;

for(int i=0;i<N;i++)
for(int j=0;j<M;j++)
left[i][j]=(j==0)?costs[i][j]:min(left[i][j-1]+costs[i][j],costs[i][j]);

for(int i=0;i<N;i++)
for(int j=M-1;j>=0;j--)
right[i][j]=(j==M-1)?costs[i][j]:min(right[i][j+1]+costs[i][j],costs[i][j]);

for(int j=0;j<M;j++)
for(int i=0;i<N;i++)
up[i][j]=(i==0)?costs[i][j]:min(up[i-1][j]+costs[i][j],costs[i][j]);

for(int j=0;j<M;j++)
for(int i=N-1;i>=0;i--)
down[i][j]=(i==N-1)?costs[i][j]:min(down[i+1][j]+costs[i][j],costs[i][j]);

int ans = numeric_limits<int>::max();
for(int i = 0;i<N;i++)
{
for(int j=0;j<M;j++)
{
ans=min(ans, up[i][j] + down[i][j] - 3*cost[i][j] + left[i][j] + right[i][j]);
}
}

return ans;

}
``````

I did this for Hotel question but it was giving Abort Error in 3 Test Cases can anyone tell me the mistake?

same here me too,why was that can anyone explain

do u pass all test cases,we were getting abort

@nvdrag123
Just asking , Im new to competitive programming
can you please tell me how did you got the idea?

link programming is mostly on the skill of googling, you just have to search.

3 Likes

how you derive this formula @nvdrag123

can anyone give me link for the questions?

for which problem @i_love_lucie

all of them…

its standard stars and bars problem i have provided link above