Skip to content
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

[mand2, yapp] week1 답안 제출 #43

Merged
merged 4 commits into from
May 5, 2024
Merged

Conversation

mand2
Copy link
Contributor

@mand2 mand2 commented May 2, 2024

  • Contains Duplicate
  • Valid Anagram
  • Two Sum
  • Valid Palindrome
  • Best Time to Buy and Sell Stock

mand2 added 2 commits May 3, 2024 00:57
- [x] Contains Duplicate
- [x] Valid Anagram
- [x] Two Sum
- [x] Valid Palindrome
- [x] Best Time to Buy and Sell Stock
[mand2] week1 답안 제출
@dev-jonghoonpark
Copy link
Contributor

.gitignore 는 빼주시면 좋을 것 같아요...! : )

@DaleSeo
Copy link
Contributor

DaleSeo commented May 3, 2024

@mand2 님, 혹시 디스코드 서버에 가입하셨나요? "mand2"라는 유저 네임이 검색되지 않으서요. 다른 분들처럼 PR 제목에 디스코드 유저 네임을 적어주시면, GitHub 유저 네임과 매칭하기가 좀 편할 것 같습니다.

Copy link
Contributor

@DaleSeo DaleSeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오답 코드가 하나 있는 것 같아서 피드백 드렸습니당!

contains-duplicate/mand2.py Show resolved Hide resolved
valid-anagram/mand2.py Outdated Show resolved Hide resolved
@DaleSeo DaleSeo added this to the week1 milestone May 3, 2024
@mand2 mand2 changed the title [mand2] week1 답안 제출 [mand2, yapp] week1 답안 제출 May 3, 2024
@DaleSeo DaleSeo added the week1 label May 3, 2024
Comment on lines 10 to 16
word_counter = {}
# s 문자열 분해
for alpha in s:
# 초기화
if alpha not in word_counter:
word_counter[alpha] = 0
word_counter[alpha] += 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
word_counter = {}
# s 문자열 분해
for alpha in s:
# 초기화
if alpha not in word_counter:
word_counter[alpha] = 0
word_counter[alpha] += 1
word_counter = defaultdict(int)
# s 문자열 분해
for alpha in s:
word_counter[alpha] += 1

위처럼 수정하면 #초기화 부분을 줄일 수 있는데 이건 어떨까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 감사합니다~! 이 부분을 미처 생각 못했었네요

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultdict 모듈 없이도 get 메서드로 기본값을 설정해줄 수도 있기는 합니다. ㅎㅎ
원하시는 방법을 사용하시면 될 것 같아요.

word_counter = {}

for alpha in s:
    word_counter[alpha] = word_counter.get(alpha, 0) + 1

Copy link
Contributor Author

@mand2 mand2 May 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WhiteHyun 다른 기능도 알려주셔서 감사합니다😊👍

two-sum/mand2.py Outdated

for i, value in enumerate(nums):
look = target_num - value
print('look:', look)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print('look:', look)

사소한 부분이지만 솔루션 제출하실 땐 print 는 빼도 좋지 않을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

복붙하다가 같이 딸려 들어갔나봐요. 감사합니다 :)

- two-sum: 쓸모없는 로그 삭제
- anagram:
    - 초기화 수정
    - 로직 추가
Copy link
Contributor Author

@mand2 mand2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.gitignore 삭제하였고, 피드백 주신 부분 반영했습니다 :)

Comment on lines 10 to 16
word_counter = {}
# s 문자열 분해
for alpha in s:
# 초기화
if alpha not in word_counter:
word_counter[alpha] = 0
word_counter[alpha] += 1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 감사합니다~! 이 부분을 미처 생각 못했었네요

two-sum/mand2.py Outdated

for i, value in enumerate(nums):
look = target_num - value
print('look:', look)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

복붙하다가 같이 딸려 들어갔나봐요. 감사합니다 :)

contains-duplicate/mand2.py Show resolved Hide resolved
valid-anagram/mand2.py Outdated Show resolved Hide resolved
Copy link
Contributor

@DaleSeo DaleSeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

피드백 반영해주셔서 감사합니다!

@SamTheKorean SamTheKorean merged commit bfd7843 into DaleStudy:main May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants