Skip to content

Conversation

taewanseoul
Copy link
Contributor

@taewanseoul taewanseoul commented Dec 18, 2024

답안 제출 문제

체크 리스트

  • 우측 메뉴에서 PR을 Projects에 추가해주세요.
  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 바로 앞에 PR을 열어주신 분을 코드 검토자로 지정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

@taewanseoul taewanseoul requested a review from a team as a code owner December 18, 2024 11:55
@github-actions github-actions bot added the ts label Dec 18, 2024
@taewanseoul taewanseoul requested a review from kdh-92 December 18, 2024 11:57
Comment on lines +9 to +16
if (n <= 2) {
return n;
}

let prev = 1;
let cur = 2;

for (let i = 3; i < n + 1; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

n을 기준으로 prev는 1, cur는 2로 하신 것 같습니다. (다른 풀이나 chatgpt도 위와 같았던 것으로 기억합니다.)

결과는 사실 상 같으나 약간 생각을 해봤을 때 n을 1부터 보는게 아니라 0부터 봐서
prev 1, cur 1로 설정하여 for문을 2 ~ n 까지 구할 수 있는 방법으로도 생각할 수 있을 것 같습니다 :)

let prev = 1, cur = 1;
for (let i = 2; i <= n; i++) {
    const next = cur;
    cur = prev + cur;
    prev = next;
}

return cur;

Comment on lines +12 to +30
const charMap = new Map<string, number>();

for (const char of s) {
const count = charMap.get(char);
if (count) {
charMap.set(char, count + 1);
} else {
charMap.set(char, 1);
}
}

for (const char of t) {
const count = charMap.get(char);
if (count) {
charMap.set(char, count - 1);
} else {
return false;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

map 풀이 방법이군요 :)

저는 문자열을 정렬해서 비교하는 방법을 떠올렸는데 javascript가 코드가 훨씬 깔끔하게 나오네요.
(효율성은 떨어집니다!)

return s.split('').sort().join('') === t.split('').sort().join('');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

그렇게도 풀이할 수 있겠군요!

Copy link
Contributor

@obzva obzva left a comment

Choose a reason for hiding this comment

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

@taewanseoul 안녕하세요 코치 Flynn입니다 한 주 수고하셨습니다 :)
@kdh-92 안녕하세요 활발한 리뷰 감사합니다 ㅎㅎ 지정된 PR에 대한 승인은 참여자 본인이 직접 하셔도 괜찮습니다
다음엔 직접 눌러주셔도 좋을 것 같아요~

@taewanseoul taewanseoul merged commit 55c004d into DaleStudy:main Dec 21, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

3 participants