Interview Question for Front-end Software Engineers

Country: India
Interview Type: Written Test

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

the sum of all the winnings should sum up to Choose(N,2). Say, current sum is NN (without the -1 values). Compute S = Choose(N,2)- NN. M is the number of persons with -1. The answer is: Choose(S+M-1, S).

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

Your solution, is not right, first of all, variables mustn't be bigger than n - 1.
Second, it is not sufficient, that sum equals (n, 2).

For example, n = 4, then (n, 2) = 4 * 3 / 2 = 6
But this test will not work,
3 3 0 0
their sum is 6, but 2 players win others, which is not possible.

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

WHY THE F do people post programming contest problems?

Comment hidden because of low score. Click to expand.
-2
of 2 vote

Here are some of my thoughts which in my opinion can be used for solving this problem:
Assuming that all players play with each other and each group consists N players:
1) Total number of scores for a particular group has to be equal N(N-1)/2 e.g
- N = 2 => total is 1
- N = 3 => total is 3
- N = 4 => total is 6
2) Max score for a particular player is N - 1 when he won all of his games
So:
For each group check if the following constraints are not violated.
If the group contains -1 values check all permutations of '-1' values replacing them with numbers from 0 - (N-1).
Sum number of all combinations which don't break constraints.

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

There could only be at most one person whose score is 0.

Comment hidden because of low score. Click to expand.
-2

Yes, there can be one 0 and one max (N -1)

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.

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.