Amazon Interview Question for SDE-2s

Country: United States
Interview Type: In-Person

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

Thinking out loud her - answer is not complete.

The remaining runs to win is T_b - T_a. It has to be achieved in 120 - B_b where B_b is the number of balls faced by Team B till now.
Now each ball has a possibility in the set { 0, 1, 2 ,3, 4, 5, 6, NoBall, Wide, Wicket }
The possibilities which contribute to runs are {1,2,3,4,5,6,Wide,NoBall}
There are 120 - B_b balls remaining lets say it is "b" for simplicity.
For each ball there are 10 possibilities and hence b*10 total possiblitites to pick from
But scoring possiblities are 8. hence b*8 possibilities
Probability of picking these possibities are b*8/b*10 = 4/5.

Its not over yet.

lets say target is T = T_a - T_b + 1

then T can be expressed as linear expression of those 8 possibilities.

let us say each coefficient in that linear expression is a_1, a_2, a_3, ....a_8.

Now lets say there are "n" such linear expressions

Out of those "n" such linear expressions only some are valid
--> when the sum of coefficients a_1 to a_8 is b

Lets say this number is "m".

If n == 0 then probability is 0
else if m == 0 then probability is 0
total probability is (4/5)*(m/n)

- Sunny August 31, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
of 0 vote

And how can we calculate this m in the solution, is dp a right approach?

- anonymous December 28, 2017 | Flag Reply

Add a Comment

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


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


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