Round 1
Questions: Given the power boosters provided to n players where the three power boosters of the ith player are defined by (power_a[i], power_b[i], power_c[i]), find the number of players who are capable of defeating all other players in a game by using their power boosters optimally.
Function Description
Complete the function findCapableWinners
in the editor.
findCapableWinners
has the following parameter:
int power_a[n]
: the first set of power boostersint power_b[n]
: the second set of power boostersint power_c[n]
: the third set of power boosters
Returns
int
: the number of players capable of defeating all other players
Example 1:
Input:
power_a = [9, 4, 2], power_b = [5, 12, 10], power_c = [11, 3, 13]
Output:
2
Explanation:
Consider the number of players to be n = 3, and their first set of power boosters to be power_a = [9, 4, 12], their second set of power boosters to be power_b = [5, 12, 10] and their third set of power boosters to be power_c = [11, 3, 13]. Thus, Player 1 has power boosters [9, 5, 11], Player 2 has [4, 12, 3] and Player 3 has power boosters [12, 10, 13].
- Player 1 can defeat Player 2 by playing in the following way: 5 against 3, 9 against 4, 11 against 12; Player 1 wins the first 2 rounds.
- Player 1 can defeat Player 3 by playing in the following way: 5 against 2, 9 against 13, 11 against 10; Player 1 wins the first and last rounds.
- Player 2 cannot defeat Player 1 using any combination of powers.
- Player 3 can defeat Player 3 by playing in the following way: 4 against 12, 10 against 3, 13 against 11; Player 3 wins the first 2 rounds.
- Player 3 can defeat Player 1 by playing in the following way: 2 against 5, 10 against 9, 13 against 11; Player 3 wins the last 2 rounds.
- Player 3 can defeat Player 2 by playing in the following way: 2 against 12, 10 against 4, 13 against 3; Player 3 wins the last 2 rounds.
Thus, Player 1 and Player 3 can defeat all the players using their power boosters optimally. Thus, the answer is 2.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.