https://leetcode.com/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/ LeetCode - The World's Leading Online Programming Learning PlatformLevel up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.leetcode.comclass Solution: def numWays(self, steps: int, arrLen: int) -> int: size = min(arrLen, steps) dp = [[0 for _ in range(size)] for _ in range(steps + 1)] dp[0][0] = 1 for i in range(1, steps + 1): for j in range(size): dp[i][j] = dp[i-1][j] if j > 0: dp[i][j] += dp[i-1][j-1] if j < size - 1: dp[i][j] += dp[i-1][j+1] dp[i][j] %= 1000000007 return dp[steps][0]dp일 수밖에 없는 문제고, 그걸 파악하면 그렇게 어렵진 않음
댓글 영역
획득법
① NFT 발행
작성한 게시물을 NFT로 발행하면 일주일 동안 사용할 수 있습니다. (최초 1회)
② NFT 구매
다른 이용자의 NFT를 구매하면 한 달 동안 사용할 수 있습니다. (구매 시마다 갱신)
사용법
디시콘에서지갑연결시 바로 사용 가능합니다.