Count Divisible Coin Selections
Updated
Problem statement
There are n coins with values from 0 to n - 1, inclusive.
Return the number of ways to select exactly k coins such that the sum of the selected coin values is divisible by m.
Return the answer modulo 10^9 + 7.
Function
countDivisibleCoinSelections(n: int, m: int, k: int) → intExamples
Example 1
n = 4m = 2k = 2return = 2The valid selections are {0,2} and {1,3}.
Example 2
n = 5m = 3k = 2return = 3Coin values are 0,1,2,3,4. The valid pairs are {0,3}, {1,2}, and {2,4}.
Constraints
1 <= n <= 2001 <= m <= 1000 <= k <= n- Coin values are exactly
0, 1, ..., n - 1. - Return the answer modulo
10^9 + 7.
More Google Online Assessment questions
- Book Reading EveningsOA · Seen Nov 2026
- Count Score CategoriesOA · Seen Nov 2026
- Minimum Cars for Rental RequestsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Shortest Path in a Binary MatrixOA · Seen Nov 2026
- Robot Assembly Line ConflictsOA · Seen Oct 2026
- Assign LockerOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Biggest Number From DigitsOA · Seen Oct 2026
- Consolidate On-Call RotationsOA · PHONE SCREEN · Seen Oct 2026
- Decreasing SubsequencesOA · Seen Sep 2026
- Minimize Absolute Difference of Server LoadsOA · Seen Sep 2026