-
-
Notifications
You must be signed in to change notification settings - Fork 248
[Joy] Week1 Solutions #20
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
Conversation
마지막 줄에 line break를 추가해주시면 좋을것 같습니다...! |
@dev-jonghoonpark |
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.
리뷰 남겼어요!
주석으로 설명 적어주시고, 테스트 케이스들도 적어주시는 꼼꼼함에 놀랐습니다!
(덕분에 릿코드에 테스트 케이스 추가하는 기능 있는 걸 알았어요 ㅎ)
''' | ||
|
||
def containsDuplicate(nums): | ||
num_set=set() |
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.
num_set 처럼 자료형을 변수 명으로 쓰는 것 보다는 의미있는 다른 이름은 어떨까요?
저는 appeared
라고 썼어요 ㅎㅎ
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.
재미있는 피드백이네요. 변수 이름 짓기가 항상 어렵죠. 저도 개인적으로 비지니스 로직을 짤 때는 변수 이름에 자료구조를 나타내는 단어를 넣는 것을 피하는 편인데요, 코딩 테스트에서는 오히려 변수에 그런 단어를 넣는 것이 면접관과 의사 소통하기가 편할 때가 있더라고요.
else: | ||
return False | ||
|
||
return all(x == 0 for x in count.values()) |
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.
모든 결과가 참이어야 true인 내장 함수인가요? 신기하네요 ㅎㅎ
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.
이 블로그 글을 읽어보시면 호기심이 좀 풀리실 것 같아요: https://www.daleseo.com/python-all/
contains-duplicate/JoyJaewon.py
Outdated
print(containsDuplicate([1, 2, 3, 1]) == True) | ||
print(containsDuplicate([1, 2, 3, 4]) == False) | ||
|
||
#Edge case | ||
print(containsDuplicate([1]) == False) | ||
print(containsDuplicate([]) == False) |
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.
2문제 남으셨네요. 화이팅! 😄
''' | ||
|
||
def containsDuplicate(nums): | ||
num_set=set() |
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.
재미있는 피드백이네요. 변수 이름 짓기가 항상 어렵죠. 저도 개인적으로 비지니스 로직을 짤 때는 변수 이름에 자료구조를 나타내는 단어를 넣는 것을 피하는 편인데요, 코딩 테스트에서는 오히려 변수에 그런 단어를 넣는 것이 면접관과 의사 소통하기가 편할 때가 있더라고요.
else: | ||
return False | ||
|
||
return all(x == 0 for x in count.values()) |
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.
이 블로그 글을 읽어보시면 호기심이 좀 풀리실 것 같아요: https://www.daleseo.com/python-all/
valid-anagram/JoyJaewon.py
Outdated
if char in count: | ||
count[char] += 1 | ||
else: | ||
count[char] = 1 |
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.
참고: 요렇게 한 줄로 짜실 수도 있습니다.
if char in count: | |
count[char] += 1 | |
else: | |
count[char] = 1 | |
count[char] = count.get(char, 0) + 1 |
#Version 2 | ||
def isPalindrome2(s): | ||
filtered_chars = [c.lower() for c in s if c.isalnum()] |
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.
V2로 분리하는 것도 좋은 생각이네요!
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.
수고하셨습니다!
No description provided.