Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions contains-duplicate/hajunyoo.py
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
9 changes: 9 additions & 0 deletions number-of-1-bits/hajunyoo.py
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)
Copy link
Contributor

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:에서 parameter nint로 받고 있기 때문에 굳이 적지 않아도 될 코드 같아요

Copy link
Contributor Author

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을 해보았습니다
나중에 한번 다시 시도해보겠습니다 ㅎㅎ

cnt = 0
while n > 0:
if n % 2 == 1:
cnt += 1
n = n // 2
return cnt