We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c901528 commit b664c6cCopy full SHA for b664c6c
unique-paths/yeonguchoe.cpp
@@ -0,0 +1,14 @@
1
+class Solution {
2
+public:
3
+ int combination(int n, int r) {
4
+ int k = n - r > r ? r : n - r;
5
+ unsigned long long result = 1;
6
+ for (int i = 0; i < k; i++) {
7
+ result = result * (n - i) / (i + 1);
8
+ }
9
+ return result;
10
11
+ int uniquePaths(int m, int n) { return combination(m - 1 + n - 1, m - 1); }
12
+ // 시간 복잡도: O(min(m,n))
13
+ // 공간 복잡도: O(1)
14
+};
0 commit comments