## himanshu.tomar05

BAN USER- 2of 2 votes

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

- himanshu.tomar05 in India| Report Duplicate | Flag | PURGE

Goldman Sachs Applications Developer Algorithm - 1of 1 vote

AnswersWe need to make a string of size n. Each character of the string is either ‘R’, ‘B’ or ‘G’. In the final string there needs to be at least r number of ‘R’, at least b number of ‘B’ and at least g number of ‘G’ (such that r + g + b <= n). We need to find number of such strings possible.

- himanshu.tomar05 in India

For example,

n = 4, r = 1, b = 1, g = 1.

Output:

36| Report Duplicate | Flag | PURGE

Directi Developer Program Engineer Algorithm

Rep**lillyalaird**, Associate at Achieve InternetI am Lilly from Eau Claire USA, I am working as a manager in a Best products company. My interest ...

Rep**kellydbrown23**, Jr. Software Engineer at Auto NInjaI live in College Park USA with my family, and my current job is clerk in Luria’s company. I ...

Rep**floydmsnyder**, Theoretical mathematician at STM Auto PartsAs a Theoretical Mathematician,I’m little more interested in the theory involved with mathematics. In my free time , I ...

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window