Участник:Kozub/umber-of-ways-to-stay-in-the-same-place-after-some-steps

Материал из DISCOPAL
Перейти к: навигация, поиск
import numpy as np
class Solution:
    def numWays(self, steps: int, arrLen: int) -> int:
        num_of_ways = np.zeros(arrLen, dtype = np.int64)
        num_of_ways[0] = 1
 
        for i in range(steps):
            tmp = num_of_ways.copy()
            tmp[1:] += num_of_ways[:-1]
            tmp[:-1] += num_of_ways[1:]
            num_of_ways = tmp % (10**9 + 7)
        return num_of_ways[0] % (10**9 + 7)