-
-
Notifications
You must be signed in to change notification settings - Fork 245
[HaJunYoo][WEEK 01] 리트코드 문제 풀이 #303
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
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6d1ee5a
[LC] feat: contains-duplicate
HaJunYoo a2d1621
[LC] feat: number-of-bits
HaJunYoo ca0a2b4
[LC] feat: top k frequent elements
HaJunYoo 833fda5
[LC] feat: top k frequent elements (bst)
HaJunYoo 6139c9c
[LC] feat: palindromic-substring
HaJunYoo 0c8f197
[LC] 240817 add time complexity
HaJunYoo b9ae750
[LC] 240818 fix line break lint
HaJunYoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Solution: | ||
def containsDuplicate(self, nums: List[int]) -> bool: | ||
string_len = len(nums) | ||
set_len = len(set(nums)) | ||
|
||
return string_len != set_len |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Solution: | ||
def hammingWeight(self, n: int) -> int: | ||
n = int(n) | ||
cnt = 0 | ||
while n > 0: | ||
if n % 2 == 1: | ||
cnt += 1 | ||
n = n // 2 | ||
return cnt |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
안녕하세요 HajunYoo님
n = int(n)
코드를 작성하신 이유가 궁금합니다 :)제 생각엔
def hammingWeight(self, n: int) -> int:
에서 parametern
을int
로 받고 있기 때문에 굳이 적지 않아도 될 코드 같아요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이 string으로 인식이 되는 에러가 발생했어서, int로 type casting을 해보았습니다
나중에 한번 다시 시도해보겠습니다 ㅎㅎ