File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ ํ์ด :
3
+ matrix์ 0th row, 0th column์ 1๋ก ๋๊ณ
4
+ matrix์ ๊ฐ ์นธ์ผ๋ก ์ค๋ ๋ฐฉ๋ฒ์ ๊ณ์ฐํ๋ค
5
+ ํ์ฌ ์นธ์ผ๋ก ์ค๋ ๋ฐฉ๋ฒ์ ์ผ์ชฝ์์ ๋๋ ์์ชฝ์์ ์ค๋ ๋ฐฉ๋ฒ ๋ฟ์ด๋ฏ๋ก
6
+ ๋์ ๋ํ ๊ฐ์ด ํ์ฌ ์นธ์ ์ค๋ ๋ฐฉ๋ฒ์ ์์ด๋ค
7
+ ์ ์ฒด matrix๊ฐ ์๋ row ํ ์ค ๋งํผ์ ๋ฐฐ์ด, cur๋ฅผ ์ด์ฉํ์ฌ
8
+ row์ ๋ํด ๋ฐ๋ณต๋ฌธ์ ๋๊ณ cur์ ๋ง์ง๋ง ์์๋ฅผ return
9
+
10
+ matrix์ ํฌ๊ธฐ m * n
11
+
12
+ TC : O(M * N)
13
+ matrix์ ๋ชจ๋ ์์๋ฅผ ์ํํ๋ฏ๋ก
14
+
15
+ SC : O(N)
16
+ cur์ ํฌ๊ธฐ๊ฐ n์ ๋น๋กํ๋ฏ๋ก
17
+ """
18
+
19
+ class Solution :
20
+ def uniquePaths (self , m : int , n : int ) -> int :
21
+ cur = [1 ] * n
22
+ for _ in range (1 , m ) :
23
+ for i in range (1 , n ) :
24
+ cur [i ] = cur [i - 1 ] + cur [i ]
25
+ return cur [- 1 ]
You canโt perform that action at this time.
0 commit comments