문제 링크 (opens new window)

# 문제 설명

  1. DP 풀이
class Solution {
    func uniquePaths(_ m: Int, _ n: Int) -> Int {
        if m == 1 || n == 1 {
            return 1
        }
        var dp: [[Int]] = .init(repeating: .init(repeating: 0, count: n+1), count: m+1)
        dp[1][2] = 1
        dp[2][1] = 1
        for row in 1...m {
            for col in 1...n {
                dp[row][col] += dp[row-1][col]
                dp[row][col] += dp[row][col-1]
            }
        }
        return dp[m][n]
    }
}