Microsoft Interview Question for Software Engineer in Tests






Comment hidden because of low score. Click to expand.
0
of 0 vote

can you please explain the problem a little bit more?
what do you mean "maximum no. of denomination."?

- test January 19, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

nahi karege

- anonymous January 22, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think for getting the maximum no of denominations, we should subtract the given number with every denominations and then doing this process again and again until you are left with 0.

- Nishant January 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This does not work. For example: x = 1100 = 1000*1 + 100*1, according to your method, we have 1000 and 100 denominations, but x = 1100 = 1000*1 + 10*9 + 1*10, we have 1000,10 and 1 denominations. We need to find all combinations of denominations, then find a maximum set.

- Xiao January 27, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

You got me wrong , when you are subtracting, then subtract from the lowest denominations, so as for your example x = 1000 , you start with subtracting $1, $2, $5 and so on again and again thereby increasing the counts of the denominations.

Hope this clears

- Nishant January 27, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

denominations: d[0]<d[1]<...<d[n-1] and d[0] = 1;
pseudo code:
initial x[i] to zero for all i
for(i=0; x>=d[i]; i=(i+1)%n)
x -= d[i];
count[i]++;
count[0] += x;

- Anonymous February 17, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

denominations: d[0]<d[1]<...<d[n-1] and d[0] = 1;
pseudo code:
initial x[i] to zero for all i

for(i=0; x>=d[i]; i=(i+1)%n)
    x -= d[i];
    count[i]++;
count[0] += x;

- Anonymous February 17, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Les assume there are 4 denominations: 1000,100,10,1 x = 1000*x1+100*x2+10*x2+1*x1.
1: 1 <= x <= 10 {1}
2: 10 < x <= 100 {10,1}
3: 100 < x <= 1000 if 1 <= x%10 < 10 {100,1} else {100,10,1}
4: x > 1000 if 1 <= x%10 < 10 {1000,1} else if 10 <= x%100 <= 100 {1000,10,1} else {1000,100,10,1}

- Xiao January 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

HashTable<Float,Integer> getDenominations (float num)
{
Hashtable<Float,Integer> table = new Hashtable<Float,Integer>();
int size =10;
if (num<0.01) // 1 cent being the smallest denomination
return null;
int[] denominations = new int[size];
denominations = {0.01, 0.05, 0.10, 0.25, 0.50, 1, 5, 10, 20, 100};
int i =0;
int count = 0;
while(i<size&& num >0.01)
{
if (num<denominations[0])
return table;
if(i =size && num > 0)
i =0;
if(num-denominatios[i]>0)
{
num = num - denominations[i];
if (table.contains(denominatios[i))
{
count = table.get(denominations[i]);
count ++;
table.put(denominations[i], count)
}
else
{
table.put(denominations[i],1)
}
}
i++;
}
else
{
i = size - 1; //to again loop through it
}
return table;

}

- Nishant January 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

try a dynamic approach for this problem , where the goal is maximize the number of the coins for change.

- Anonymous February 01, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Backtracking should generate all possible combinations, but it is exponential in time usage.

- Anonymous February 23, 2010 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More