-
-
Notifications
You must be signed in to change notification settings - Fork 245
[sun] W1 Solutions #315
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
[sun] W1 Solutions #315
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6d8c598
contains-duplicate solution
sun912 f74db69
Time complexity added
sun912 e0ae448
number-of-1-bits solution
sun912 4841b41
top-k-frequent-elements solution
sun912 eb1c165
top-k-frequent-elements solve
sun912 8b22e3f
comment changed
sun912 eda20ca
solved palindromic-substrings
sun912 79de0bc
kth-smallest-element-in-a-bst solution
sun912 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,8 @@ | ||
""" | ||
Time complexity: O(n) | ||
""" | ||
|
||
class Solution: | ||
def containsDuplicate(self, nums: List[int]) -> bool: | ||
nums_set = set(nums) | ||
return len(nums_set) != len(nums) |
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,13 @@ | ||
""" | ||
TC: O(log n) | ||
SC: O(1) | ||
""" | ||
|
||
class Solution: | ||
def hammingWeight(self, n: int) -> int: | ||
result = 0 | ||
while n > 0: | ||
result += n % 2 | ||
n = n//2 | ||
|
||
return result | ||
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.
옷, 파일 마지막에 line break가 빠져있네요.
참고: https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline
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.
오이잇 감사합니다~=)
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.
저는 Python 컨벤션으로 알고 있었는데, 근본의 UNIX 기원이군요 감사합니다