Scribbling

프로그래머스: 등굣길 본문

Computer Science/Coding Test

프로그래머스: 등굣길

focalpoint 2021. 10. 26. 21:19
def solution(m, n, puddles):   
    dp = [[0] * m for _ in range(n)]
    dp[0][0] = 1
    for i in range(1, m):
        if [i+1, 1] in puddles:
            continue
        dp[0][i] = dp[0][i-1]
    for i in range(1, n):
        if [1, i+1] in puddles:
            continue
        dp[i][0] = dp[i-1][0]
    for i in range(1, n):
        for j in range(1, m):
            if [j+1, i+1] in puddles:
                continue
            dp[i][j] = dp[i-1][j] + dp[i][j-1]
    return dp[n-1][m-1] % 1000000007