Skip to content

[rlawjd10] WEEK 02 solutions #1763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions climbing-stairs/rlawjd10.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 피보나치 수열
class Solution {
public:
int climbStairs(int n) {

int prev1 = 1;
int prev2 = 1;

if (n == 1) return prev1;

for (int i = 2; i <= n; i++) {
int current = prev1 + prev2;
prev2 = prev1;
prev1 = current;
}

return prev1;
}
};


16 changes: 16 additions & 0 deletions valid-anagram/rlawjd10.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 모든 철자가 있는지 확인
class Solution {
public:
bool isAnagram(string s, string t) {
// 1. 문자열 정렬
sort(s.begin(), s.end());
sort(t.begin(), t.end());

// 2. 비교
if (s.compare(t) == 0)
return 1;

return 0;
}
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sort를 사용해서 코드가 짧아서 가독성은 좋네요!!
nlogn이 아닌 n의 시간복잡도로 할 수 있는 방식도 있으니 참고하시면 될 것 같아요

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오! 감사합니다~ 한 번 시도해봐야겠어요!!