Skip to content

[sun] WEEK 5 solution #450

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 7 commits into from
Sep 16, 2024
Merged

[sun] WEEK 5 solution #450

merged 7 commits into from
Sep 16, 2024

Conversation

sun912
Copy link
Contributor

@sun912 sun912 commented Sep 10, 2024

답안 제출 문제

  • Best Time to Buy And Sell Stock
  • Group Anagrams
  • 3Sum

체크 리스트

  • PR을 프로젝트에 추가하고 Week를 현재 주차로 설정해주세요.
  • 바로 앞에 PR을 열어주신 분을 코드 검토자로 지정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 Status를 In Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

@sun912 sun912 added the py label Sep 10, 2024
@sun912 sun912 requested a review from a team as a code owner September 10, 2024 13:17
@sun912 sun912 requested a review from jdalma September 10, 2024 13:18
@sun912 sun912 marked this pull request as draft September 10, 2024 13:19
@sun912 sun912 marked this pull request as ready for review September 13, 2024 08:10
@DaleSeo
Copy link
Member

DaleSeo commented Sep 13, 2024

  • 3Sum

3Sum 풀었다고 체크가 되어 있는데 빈 파일이네요?

Shot 2024-09-13 at 17 22 46@2x

3sum solution
Copy link
Contributor

@bky373 bky373 left a comment

Choose a reason for hiding this comment

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

파이썬으로 간결하게 작성된 코드가 이해가 잘 되었습니다 고생하셨습니다!

l = 0
r = 1

while r < len(prices):
Copy link
Contributor

Choose a reason for hiding this comment

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

코드 내용 잘 보았습니다! two pointer를 이용한 솔루션 자체는 이해가 잘 되는데요 아래와 같은 방법으로 조금 더 간결하게 적을 수 있지 않을까 싶어 코멘트 드립니다 😄

max_profit=0
buy = 0 ## l,r 대신 사는날의 인덱스만 표기

for sell in range(1, len(prices)): ## while loop 대신 for loop을 이용해서 sell 포인터를 안으로 포함시켜버리기

이렇게 개선하면 조금 더 간결하게 쓸 수 있을거 같아요!

result.add((nums[i], nums[left], nums[right]))
left,right = left+1, right-1

return list(result)
Copy link
Contributor

@leokim0922 leokim0922 Sep 14, 2024

Choose a reason for hiding this comment

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

코드 전반적인 내용은 잘 이해가 됩니다만, 요 부분이 조금 신경이 쓰이네요 ㅎㅎ 혹시 result를 시작부터 list로 작성하는 방법도 생각해보셨을까요? 캐스팅을 하더라도 Time complexity가 유의미한 변화가 없는건 이해가 갑니다만, set을 사용하지 않으면 메모리 측면에서 조금 유리하지 않을까 생각이 드네요 😃

@SamTheKorean SamTheKorean merged commit 6fafc33 into DaleStudy:main Sep 16, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

5 participants