1420. Build Array Where You Can Find The Maximum Exactly K Comparisons
Last updated
Last updated
https://leetcode.com/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons
Given three integers n
, m
and k
. Consider the following algorithm to find the maximum element of an array of positive integers:
You should build the array arr which has the following properties:
arr
has exactly n
integers.
1 <= arr[i] <= m
where (0 <= i < n)
.
After applying the mentioned algorithm to arr
, the value search_cost
is equal to k
.
Return the number of ways to build the array arr
under the mentioned conditions. As the answer may grow large, the answer must be computed modulo 10^9 + 7
.
Example 1:
Example 2:
Example 3:
Example 4:
Example 5:
Constraints:
1 <= n <= 50
1 <= m <= 100
0 <= k <= n