hardCombinatoricsMath 0 views

Count the Number of Arrays with K Matching Adjacent Elements

You are given three integers n, m, k.

You are given three integers n, m, k. A good array arr of size n is defined as follows:

Return the number of good arrays that can be formed.

Since the answer may be very large, return it modulo 10^9 + 7.

Example 1

Input: n = 3, m = 2, k = 1

Output: 4

Example 2

Input: n = 4, m = 2, k = 2

Output: 6

Example 3

Input: n = 5, m = 2, k = 0

Output: 2

Constraints

  • 1 <= n <= 10^5
  • 1 <= m <= 10^5
  • 0 <= k <= n - 1

Hints

Companies

No companies reported yet.

Discussion

Sign in to join the discussion.

Loading discussion...

Test results

No test cases yet.