Skip to content

Commit 3da51cb

Browse files
authored
Merge pull request #1763 from rlawjd10/main
[rlawjd10] WEEK 02 solutions
2 parents c10bdfe + 4381785 commit 3da51cb

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

climbing-stairs/rlawjd10.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// 피보나치 수열
2+
class Solution {
3+
public:
4+
int climbStairs(int n) {
5+
6+
int prev1 = 1;
7+
int prev2 = 1;
8+
9+
if (n == 1) return prev1;
10+
11+
for (int i = 2; i <= n; i++) {
12+
int current = prev1 + prev2;
13+
prev2 = prev1;
14+
prev1 = current;
15+
}
16+
17+
return prev1;
18+
}
19+
};
20+
21+

valid-anagram/rlawjd10.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// 모든 철자가 있는지 확인
2+
class Solution {
3+
public:
4+
bool isAnagram(string s, string t) {
5+
// 1. 문자열 정렬
6+
sort(s.begin(), s.end());
7+
sort(t.begin(), t.end());
8+
9+
// 2. 비교
10+
if (s.compare(t) == 0)
11+
return 1;
12+
13+
return 0;
14+
}
15+
};
16+

0 commit comments

Comments
 (0)