class Solution(object):
def __init__(self):
self.cnt={}
self.cnt[(0,0)]=1
def uniquePaths(self, m, n):
"""
:type m: int
:type n: int
:rtype: int
"""
if m<=0 or n<=0:
return 0
for i in xrange(0,m):
for j in xrange(0,n):
if (i,j) in self.cnt:
continue
cnt = 0
if i>0:
cnt += self.cnt[(i-1,j)]
if j>0:
cnt += self.cnt[(i,j-1)]
self.cnt[(i,j)] = cnt
return self.cnt[(m-1,n-1)]