-
[LeetCode] DP / Unique-paths알고리즘 2022. 6. 14. 21:16
class Solution: def uniquePaths(self, r: int, c: int) -> int: if (r == 1 or c == 1): return 1 dp = [[1] * c for _ in range(r)] for i in range(1, r): for j in range(1, c): dp[i][j] = dp[i-1][j] + dp[i][j-1] return dp[r-1][c-1]
'알고리즘' 카테고리의 다른 글
[LeetCode] 438. Find All Anagrams in a String (0) 2022.06.21 Manacher's Algorithm [가장 긴 펠렌드롬 찾기] (0) 2022.06.20 [LeetCode] HashTable/ 73. Set Matrix Zeroes (0) 2022.06.12 [Leetcode] 플로이드와샬 / 1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance (0) 2022.06.11 [LeetCode] 1905. Count Sub Islands (0) 2022.06.02