Skip to content

Commit 908440e

Browse files
committed
unique paths
1 parent 462899e commit 908440e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

unique-paths/jungsiroo.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from math import comb
2+
3+
class Solution:
4+
def uniquePaths(self, m: int, n: int) -> int:
5+
# mathematic way
6+
# 중학교 때 배운 최단거리 조합으로 구하기 문제
7+
# 문제 자체가 오른쪽, 아래밖에 못가기에 최단거리가 될 수 밖에 없음
8+
9+
"""
10+
TC : O(max(m, n))
11+
SC : O(1)
12+
"""
13+
14+
return comb(m+n-2, m-1)
15+

0 commit comments

Comments
 (0)