Problem Solving/LeetCode
Today's Challenge
fabichoi
2022. 8. 1. 23:45
https://leetcode.com/problems/unique-paths/
Unique Paths - LeetCode
Level 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.com
DP를 이용한 간단한 풀이 문제.
나에겐 그닥 간단친 않음 ㅠㅠ
class Solution:
def uniquePaths(self, m: int, n: int) -> int:
def solve(y, x):
if y == m-1 or x == n-1:
return 1
if dp[y][x] != 0:
return dp[y][x]
dp[y][x] = solve(y+1, x) + solve(y, x+1)
return dp[y][x]
dp = [[0 for x in range(n)] for y in range(m)]
return solve(0,0)
반응형