-
-
Notifications
You must be signed in to change notification settings - Fork 195
[혜준] Week2 문제 풀이 #351
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
[혜준] Week2 문제 풀이 #351
Conversation
복잡도 분석은 코드에(도) 주석으로 남겨주시면 리뷰하시는 분들이 더 편할 것 같습니다. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다!
console.log(countBits(5)); | ||
|
||
/* | ||
시간 복잡도: O(n * log n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세요~ 어떤 이유로 시간 복잡도가 n log n 이 나오는지, 여기서 n은 무엇을 가리키는지 설명해주시면 더 좋을 것 같아요! 나중에 실제 코딩 테스트 면접에서도 도움이 될 거라고 생각합니다
let result = []; | ||
|
||
for (let i = 0; i <= n; i++) { | ||
|
||
let binary = i.toString(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let result = []; | |
for (let i = 0; i <= n; i++) { | |
let binary = i.toString(2); | |
�const result = []; | |
for (let i = 0; i <= n; i++) { | |
const binary = i.toString(2); |
저는 재할당 되지 않을 변수는 const 키워드로 선언하는 편인데요. 이는 코드를 읽는 사람으로 하여금 이 변수는 재할당되지 않을 것임을 예측할 수 있도록 해주고, 나중에 실수로 해당 변수에 다른 값을 할당하게 되는 버그를 사전에 예방할 수 있기 때문이에요.
Valid Anagram
시간 복잡도: O(n)
공간 복잡도: O(n)
Counting Bits
시간 복잡도: O(n * log n)
공간 복잡도: O(n)