Mode: On-Campus Exam Pattern: 3 DSA qs in 90 mins OA Date: 2026-10-25
Two players, Player 1 and Player 2, play a game using N trays, where the i-th tray contains A[i] candies.
The rules of the game are as follows:
Determine the number of distinct arrangements of the trays for which Player 1 wins, assuming both players play optimally.
For this version, assume that arrangements are considered distinct by position, even when some trays contain the same number of candies, and that every tray contains a positive integer number of candies.
Print a single integer representing the number of arrangements that allow Player 1 to win.
Input
3
1 2 3
Output
6
Explanation
There are 3 trays, containing 1, 2, and 3 candies. Under the assumed rules, the order of the trays does not affect the possible moves or the outcome of the game. Therefore, either all six positional arrangements allow Player 1 to win, or none do.
For this illustrative example, assume Player 1 wins for this set of tray sizes. Since all three tray sizes are distinct, there are 3! = 6 distinct arrangements, so the answer is 6.
THOUGHTSPOT • 114 views
THOUGHTSPOT • 104 views
THOUGHTSPOT • 111 views
THOUGHTSPOT • 195 views