Interview Question for Financial Software Developers






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

This is equal to 1-(probability that they all carry different number of passengers). That probability in paranthesis is equal to (m+1)!/((m+1-n)! * (m+1)^n). This is given that (m+1) >= n. If (m+1) < n, then the probability is 1.

- m+1 because maximum m passengers mean m+1 different possiblities (a bus could carry 0 passengers).
- The first bus has (m+1) possibilities in terms of number of passengers. The second has m+1, the third has m+1 and so on. Total number of orderings possible is (m+1) ^ n.
- For the number of passengers to be different in each bus, first bus has m+1 possibilities, second has m, third has m-1 nd so on. For n buses, this is equal to (m+1)!/(m+1-n)!. Dividing this by (m+1)/n gives the possibility. Subtract this number from one to find at least two buses with the same amount of passengers.

- barcod April 09, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

(...) dividing this by (m+1)^n (...)

- barcod April 09, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

How is it (m+1)!/(m+1-n)! ? I think it is (m+1)!/(m-1-n)! for the number of passengers to be different on each bus. What do you say?

- Anonymous April 09, 2011 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

If you plug the numbers in you'll see that your equation won't work for when there are two buses with max 1 passenger. You multiply m+1 with m, m-1, m-2, etc and do this n steps. M+1-n factorial is to cancel out the remaining terms in m+1! after nth step.

- Barcod April 10, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

can u tell me how u calculated this (m+1)!/(m+1-n)! r u using nCr N!/(N-R)!*R!

- Algoseekar April 10, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Algoseeker: It is nPr = n!/(n-r)!.

- barcod April 10, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

should we assume that probability of a bus carrying 0,1,2,3,.. m are all equal

- Anonymous April 10, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

That is what the solution assumes. Otherwise you'd need the pdf.

- barcod April 10, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

1-(((m+1)Cn)n!/(m+1)^n)

- Sathya April 11, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

my answer is: 1-(m*(m-1)*...*(m-n+1)/n!)/M^n

- emily May 16, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

The correct answer should be:
1 - ( (m+1)! / (m-n-1)! ) / ( (m+1)^n )

- Kevin February 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This is what I think:

1 - P (all the buses having distinct numbers of passengers)

Which boils down to:

1 - m * (m - 1) * ... * (m - (n - 1))

(you can derive this with principle of counting)

Which is:

1 - m! / (m - n)!

Now, an important assumption here is that

m > n

otherwise the answer is just

1

, because no matter how you allocate passengers to buses, at least two of the buses will have equal passengers.

Please correct me if I'm wrong.

- Anonymous October 03, 2013 | 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