Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

[2023-10-02] wooyeol #296#314

Merged
Woo-Yeol merged 1 commit into
mainfrom
wooyeol-#296
Oct 11, 2023
Merged

[2023-10-02] wooyeol #296#314
Woo-Yeol merged 1 commit into
mainfrom
wooyeol-#296

Conversation

@Woo-Yeol
Copy link
Copy Markdown
Member

@Woo-Yeol Woo-Yeol commented Oct 6, 2023

PR Summary

주식가격
https://school.programmers.co.kr/learn/courses/30/lessons/42584?language=python3

풀이시간
11:30 ~ 11:50 (20분)

문제 조건
1 <= prices의 각 가격 <= 10,000
2 <= prices의 길이 <= 100,000

시간 복잡도 :
O(N(N+1)/2)

접근법
무슨 알고리즘으로 풀이 할 수 있을까? -> 큐 와 스택

문제를 잘못 읽어 10,000개의 데이터 인줄 알고 시간 복잡도를 생각하지않고 풀이했는데
다시보니 100,000개인 것을 확인하였습니다.

그럼 이 풀이로는 풀이가 되지 않아야하는 의아함이 들어 다른 풀이를 참조하였습니다.

풀이 참고 : https://velog.io/@soo5717/프로그래머스-주식가격-Python

해당 풀이를 참고했을 때 2배 정도 빠른 효율성 테스트 결과를 확인 할 수 있었습니다.

@Woo-Yeol Woo-Yeol requested a review from limstonestone October 6, 2023 13:21
@Woo-Yeol Woo-Yeol self-assigned this Oct 6, 2023
@Woo-Yeol Woo-Yeol linked an issue Oct 6, 2023 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

@zsmalla zsmalla left a comment

Choose a reason for hiding this comment

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

갠적으로 머리 깨질 것 같았던 문제인데, 참고해주신 풀이가 와닿았어서 다시 한 번 생각해볼 수 있었던 것 같아요! 고생하셨습니다~

Comment thread Programmers/주식가격/wooyeol.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

이렇게 먼저 역으로 한 인덱스에서 가질 수 있는 최대값을 정의해주는 방법이 훨씬 와닿았던 것 같습니다!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

저도 이 부분을 스택에 남은 원소들에 대해 처리해줬었는데 이렇게 구현하는게 훨씬 간결하고 가독성이 좋은 것 같아요!! 고생하셨습니다 우열님 👍👍

Comment thread Programmers/주식가격/wooyeol.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

저도 이 부분을 스택에 남은 원소들에 대해 처리해줬었는데 이렇게 구현하는게 훨씬 간결하고 가독성이 좋은 것 같아요!! 고생하셨습니다 우열님 👍👍

@Woo-Yeol Woo-Yeol merged commit f138dbc into main Oct 11, 2023
@Woo-Yeol Woo-Yeol deleted the wooyeol-#296 branch October 11, 2023 15:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Programmers] 주식가격

3 participants