TikTok Credits Distribution Challenge
Learn this problemProblem statement
In the grand finale of a prestigious TikTok tournament, the organizers have prepared several boxes filled with TikTok credits as prizes for the participants. They know exactly how many participants will compete in the tournament and want to ensure that every participant receives an equal number of TikTok credits to avoid any disappointment. The rules of the tournament are strict: once a prize box is opened, all the TikTok credits inside it must be distributed.
A way consists of choosing a non-empty subset of prize boxes. The credits from all chosen boxes can be distributed equally when their total is divisible by participants. Count the number of such subsets and return the result modulo 10^9 + 7. If no non-empty subset works, return 0.
Function
canDistributeCredits(participants: int, credits: int[]) → intComplete the function canDistributeCredits.
int participants: the number of participantsint credits[n]: the number of credits in each box
Returns
int: the number of valid non-empty subsets modulo 10^9 + 7.
Examples
Example 1
participants = 6credits = [12, 18, 24, 36]return = 15Every credit value is divisible by 6, so the sum of every non-empty subset is also divisible by 6. Four boxes have 2^4 - 1 = 15 non-empty subsets.
Example 2
participants = 5credits = [7, 3, 6]return = 1The only valid non-empty subset is {7, 3}, whose total is 10 and is divisible by 5.
Constraints
1 <= n <= 10^61 <= participants <= 10^31 <= credits[i] <= 10^9n * participants <= 10^7
More Tiktok problems
- Count Access Code PairsOA · Seen Jul 2026
- Count Key ChangesOA · Seen Jul 2026
- Travel Distance on ScootersOA · Seen Jul 2026
- Count Skipped Numbers After SubtractionsOA · Seen Jul 2026
- Obstacle Placement QueriesOA · Seen Jul 2026
- Repeated Grouped Digit SumOA · Seen Jul 2026
- Count Cyclic Digit PairsOA · Seen Jun 2026
- Event ID Check Completion TimesOA · Seen Jun 2026