#62
Unique Paths
medium· 2-D DPruns: 0There is a robot on an m x n grid initially located at the top-left corner. It tries to move to the bottom-right corner and can only move down or right at any point. Given the two integers m and n, return the number of possible unique paths to reach the bottom-right corner.
sign in to paste and practice your own solution
wpm 0acc 100%time 0:000 / 208
class Solution:
def uniquePaths(self, m: int, n: int) -> int:
dp = [1] * n
for i in range(1, m):
for j in range(1, n):
dp[j] += dp[j - 1]
return dp[-1]
click the box to focus · tab inserts 4 spaces · backspace to correct · esc to pause
desktop only
codedrill is a typing game and needs a real keyboard. open this on a laptop or desktop to practice.
you can still browse problems and sections from your phone.