Skip to content

Commit 2f8b5a9

Browse files
authored
Merge branch 'DaleStudy:main' into main
2 parents 66a9ac0 + 05c0932 commit 2f8b5a9

File tree

129 files changed

+4469
-36
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+4469
-36
lines changed

.github/labeler.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
js:
2+
- changed-files:
3+
- any-glob-to-any-file:
4+
- "**/*.js"
5+
6+
ts:
7+
- changed-files:
8+
- any-glob-to-any-file:
9+
- "**/*.ts"
10+
11+
py:
12+
- changed-files:
13+
- any-glob-to-any-file:
14+
- "**/*.py"
15+
16+
java:
17+
- changed-files:
18+
- any-glob-to-any-file:
19+
- "**/*.java"
20+
21+
c++:
22+
- changed-files:
23+
- any-glob-to-any-file:
24+
- "**/*.cpp"
25+
26+
swift:
27+
- changed-files:
28+
- any-glob-to-any-file:
29+
- "**/*.swift"
30+
31+
kotlin:
32+
- changed-files:
33+
- any-glob-to-any-file:
34+
- "**/*.kt"
35+
36+
go:
37+
- changed-files:
38+
- any-glob-to-any-file:
39+
- "**/*.go"
40+
41+
elixir:
42+
- changed-files:
43+
- any-glob-to-any-file:
44+
- "**/*.exs"

.github/workflows/automation.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,16 @@ jobs:
1111
pull-requests: write
1212
steps:
1313
- uses: toshimaru/[email protected]
14+
15+
label-lang:
16+
runs-on: ubuntu-latest
17+
continue-on-error: true
18+
19+
permissions:
20+
contents: read
21+
pull-requests: write
22+
23+
steps:
24+
- uses: actions/labeler@v5
25+
with:
26+
repo-token: ${{ github.token }}

climbing-stairs/HC-kang.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// T.C. O(n)
2+
// S.C. O(1)
3+
function climbStairs(n: number): number {
4+
let p = 0;
5+
let q = 1;
6+
for (let i = 0; i < n; i++) {
7+
q = q + p;
8+
p = q - p;
9+
}
10+
return q;
11+
}

climbing-stairs/TonyKim9401.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public int climbStairs(int n) {
3+
// Time complexity: O(n);
4+
// Space complexity: O(n);
5+
int[] dp = new int[n+1];
6+
7+
if (n >= 1) dp[1] = 1;
8+
if (n >= 2) dp[2] = 2;
9+
10+
for (int i = 3; i <= n; i++) {
11+
dp[i] = dp[i-1] + dp[i-2];
12+
}
13+
return dp[n];
14+
}
15+
}

climbing-stairs/flynn.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public:
3+
int climbStairs(int n) {
4+
vector<int> memo(2, 1);
5+
6+
for (int i = 2; i <= n; i++) {
7+
memo.push_back(memo[i - 1] + memo[i - 2]);
8+
}
9+
10+
return memo[n];
11+
}
12+
13+
};

climbing-stairs/gitsunmin.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* https://leetcode.com/problems/climbing-stairs
3+
* time complexity : O(n)
4+
* space complexity : O(1)
5+
*/
6+
7+
export const upStairs = (n: number): number => {
8+
let [l, r] = [1, 2];
9+
for (let i = 3; i <= n; i++) [l, r] = [r, l + r];
10+
11+
return r;
12+
};
13+
14+
export function climbStairs(n: number): number {
15+
if (n <= 2) return n;
16+
return upStairs(n);
17+
};

climbing-stairs/haklee.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""TC: O(n), SC: O(1)
2+
3+
아이디어:
4+
계단의 k번째 칸까지 도달하는 방법의 수를 f(k)라고 하자.
5+
f(k)는 다음의 두 경우의 수를 더한 값이다.
6+
- k-2번째 칸까지 간 다음 두 칸 뜀. 즉, f(k-2)
7+
- k-1번째 칸까지 간 다음 두 칸 뜀. 즉, f(k-1)
8+
즉, f(k) = f(k-2) + f(k-1)
9+
10+
11+
SC:
12+
- tabulation 과정에서 값 2개만 계속 유지한다.
13+
- 즉, O(1).
14+
15+
TC:
16+
- 단순 덧셈 계산(O(1))을 O(n)번 반복한다.
17+
- 즉, O(n).
18+
"""
19+
20+
21+
class Solution:
22+
def climbStairs(self, n: int) -> int:
23+
a, b = 1, 1
24+
for _ in range(n - 1):
25+
a, b = b, a + b
26+
return b

climbing-stairs/heozeop.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Time Complexity: O(n)
2+
// Spatial Complexity: O(n)
3+
4+
class Solution {
5+
public:
6+
int climbStairs(int n) {
7+
vector<int> dp(n + 1, 0);
8+
9+
if (n == 1) {
10+
return 1;
11+
}
12+
13+
dp[0] = dp[1] = 1;
14+
for(int i = 2; i <= n; ++i) {
15+
dp[i] = dp[i - 1] + dp[i - 2];
16+
}
17+
18+
return dp[n];
19+
}
20+
};

climbing-stairs/highball.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const climbStairs = function (n) {
2+
const dp = [1, 1];
3+
4+
for (let i = 0; i < n - 1; i++) {
5+
const temp = dp[1];
6+
dp[1] = temp + dp[0];
7+
dp[0] = temp;
8+
}
9+
10+
return dp[1];
11+
};

climbing-stairs/hwanmini.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// 시간복잡도 O(n)
2+
// 공간복잡도 O(n)
3+
4+
/**
5+
* @param {number} n
6+
* @return {number}
7+
*/
8+
var climbStairs = function(n) {
9+
const stairs = [1, 2]
10+
11+
for (let i = 2; i < n; i++) {
12+
stairs[i] = stairs[i-1] + stairs[i-2]
13+
}
14+
15+
return stairs[n-1]
16+
};
17+
18+
console.log(climbStairs(5))

0 commit comments

Comments
 (0)