Class Solution
-
- All Implemented Interfaces:
public final class Solution3179 - Find the N-th Value After K Seconds\.
Medium
You are given two integers
nandk.Initially, you start with an array
aofnintegers wherea[i] = 1for all0 <= i <= n - 1. After each second, you simultaneously update each element to be the sum of all its preceding elements plus the element itself. For example, after one second,a[0]remains the same,a[1]becomesa[0] + a[1],a[2]becomesa[0] + a[1] + a[2], and so on.Return the value of
a[n - 1]afterkseconds.Since the answer may be very large, return it modulo <code>10<sup>9</sup> + 7</code>.
Example 1:
Input: n = 4, k = 5
Output: 56
Explanation:
Example 2:
Input: n = 5, k = 3
Output: 35
Explanation:
Constraints:
1 <= n, k <= 1000
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final IntegervalueAfterKSeconds(Integer n, Integer k)-
-
Method Detail
-
valueAfterKSeconds
final Integer valueAfterKSeconds(Integer n, Integer k)
-
-
-
-