Skip to content

[EGON] Week 5 Solutions #456

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

[EGON] Week 5 Solutions #456

merged 1 commit into from
Sep 16, 2024

Conversation

EgonD3V
Copy link
Contributor

@EgonD3V EgonD3V commented Sep 13, 2024

답안 제출 문제

체크 리스트

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

@EgonD3V EgonD3V added the py label Sep 13, 2024
@EgonD3V EgonD3V self-assigned this Sep 13, 2024
@EgonD3V EgonD3V requested a review from Sunjae95 September 13, 2024 18:47
@EgonD3V EgonD3V marked this pull request as ready for review September 13, 2024 18:47
@EgonD3V EgonD3V requested a review from a team as a code owner September 13, 2024 18:47
Copy link
Member

@Sunjae95 Sunjae95 left a comment

Choose a reason for hiding this comment

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

금주 수고많으셨습니다 👍

"""
def solveWithStack(self, prices: List[int]) -> int:
max_profit = 0
stack = []
Copy link
Member

Choose a reason for hiding this comment

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

스택의 개념을 사용한 의미는 전달이 되는 코드인거같아요
이렇게 되면 스택의 최대 사이즈는 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.

말씀하신 것처럼 스택을 썼음을 명시하려고 사용했습니다. 그냥 정수형 변수 하나를 사용하면 이 문제는 상관없겠지만, 문제를 풀며 생각한 사고 방식을 위해 스택을 썼습니다. 예를 들어 n개의 주식 혹은 다른 조건이 붙어도 스택을 사용하는 방식이 유효할 것이라 생각해서 사용했습니다.

anagram_dict = {}
for string in strs:
key = ''.join(sorted(string))
anagram_dict[key] = anagram_dict.get(key, []) + [string]
Copy link
Member

Choose a reason for hiding this comment

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

파이썬에서 기존배열에 다른 배열을 합치려면 이렇게 표현하는군요 👍

def solveWithHashableKey(self, strs: List[str]) -> List[List[str]]:
anagram_dict = {}
for string in strs:
key = ''.join(sorted(string))
Copy link
Member

Choose a reason for hiding this comment

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

시간복잡도를 O(L * log L) * O(L) 이라고 해주셨는데요
제가 파이썬을 잘몰라서 잠깐 찾아본 얕은 지식으로는 sorted와 join은 독립된 연산으로 동작하는거 같아 질문드려요
저는 해당 코드의 시간복잡도가 O(L * log L)라고 생각하는데 EGON님은 어떻게 생각하시나요??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

길이가 L인 문자열에 대한 sorted에서 O(L * Log L), 정렬된 길이가 L인 배열을 하나의 문자열로 만드는데 O(L)이니 O(L * Log L) * O(L)이 맞는 것 같습니다

@DaleSeo
Copy link
Member

DaleSeo commented Sep 15, 2024

  • PR을 프로젝트에 추가하고 Week를 현재 주차로 설정해주세요.

위 항목이 체크는 되어 있는데 Week 설정이 안 되어 있어서 PR을 늦게 발견하게 되었네요. 이번 PR을 제가 실정해드릴테니 다음 PR부터는 신경 좀 써주시면 감사하겠습니다 🙏

Shot 2024-09-14 at 20 50 40@2x

@SamTheKorean SamTheKorean merged commit 6411e48 into DaleStudy:main Sep 16, 2024
3 checks passed
@EgonD3V
Copy link
Contributor Author

EgonD3V commented Sep 17, 2024

죄송합니다 다음부터 더 신경쓰도록 하겠습니다 수정해주셔서 감사합니다.

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.

4 participants