Skip to content

[gitsunmin] WEEK 01 Solutions #323

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 6 commits into from
Aug 16, 2024
Merged

[gitsunmin] WEEK 01 Solutions #323

merged 6 commits into from
Aug 16, 2024

Conversation

gitsunmin
Copy link
Contributor

다섯 문제 제출합니다 🙏

@gitsunmin gitsunmin self-assigned this Aug 13, 2024
*/
function containsDuplicate(nums: number[]): boolean {
return new Set(nums).size !== nums.length
};
Copy link
Member

Choose a reason for hiding this comment

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

파일 마지막에 line break를 추가해주실 수 있으실까요? 코드 포멧터를 쓰시면 자동으로 추가될겁니다. (참고: https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

수정했습니다 감사합니다~

Comment on lines +6 to +8
function hammingWeight(n: number): number {
return n.toString(2).replaceAll('0', '').length
}
Copy link
Contributor

Choose a reason for hiding this comment

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

이렇게 간단하게 해결하는 방법도 있었네요! 👍👍

Comment on lines +7 to +12
const expandAroundCenter = (s: string, left: number, right: number): number => {
if (left < 0 || right >= s.length || s[left] !== s[right]) {
return 0;
}
return 1 + expandAroundCenter(s, left - 1, right + 1);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

안녕하세요! expandAroundCenter 함수를 countSubstrings 외부로 뺀 이유가 있으실까요?
countSubstrings 안에서 함수를 정의하면 파라매터로 s를 굳이 넘겨주지 않아도 될 것 같습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nhistory
안녕하세요
아 넵 함수 내에서 다른 스코프의 변수를 참조하는게 안 좋다고 생각해서 파라미터로 받도록 했어요

Copy link
Contributor

Choose a reason for hiding this comment

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

side effect를 고려하는 좋은 사고라고 생각합니다 어떤 분은 그런 pure function은 네이밍 컨벤션을 calc로 시작하도록 맞추기도 하시더라고요

@gitsunmin gitsunmin added the ts label Aug 15, 2024
@EgonD3V EgonD3V requested review from EgonD3V and removed request for EgonD3V August 16, 2024 12:56
Comment on lines +7 to +12
const expandAroundCenter = (s: string, left: number, right: number): number => {
if (left < 0 || right >= s.length || s[left] !== s[right]) {
return 0;
}
return 1 + expandAroundCenter(s, left - 1, right + 1);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

side effect를 고려하는 좋은 사고라고 생각합니다 어떤 분은 그런 pure function은 네이밍 컨벤션을 calc로 시작하도록 맞추기도 하시더라고요

@gitsunmin gitsunmin merged commit ea9d6c0 into DaleStudy:main Aug 16, 2024
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.

4 participants