250x250
Link
๋์ GitHub Contribution ๊ทธ๋ํ
Loading data ...
Notice
Recent Posts
Recent Comments
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- ์ค๋ฒ์ํ๋ง
- ์ธ๋์ํ๋ง
- ํ ์คํธ๋ถ์
- t-test
- ADP
- ๋์ํ๋ณธ
- PCA
- ๋ฐ์ดํฐ๋ถ์์ ๋ฌธ๊ฐ
- ์ฃผ์ฑ๋ถ๋ถ์
- ๋ฐ์ดํฐ๋ถ์์ค์ ๋ฌธ๊ฐ
- dataframe
- ํฌ๋กค๋ง
- ADsP
- ๋ฐ์ดํฐ๋ถ๊ท ํ
- Python
- ํ์ด์ฌ
- ๋ ๋ฆฝํ๋ณธ
- iloc
- datascience
- Lambda
- opencv
- DBSCAN
- LDA
- ๋น ๋ฐ์ดํฐ
- ์๋ํด๋ผ์ฐ๋
- ๋ฐ์ดํฐ๋ถ์
- pandas
- ๋น ๋ฐ์ดํฐ๋ถ์๊ธฐ์ฌ
- ๊ตฐ์งํ
- numpy
Archives
Data Science LAB
[Python] ํ๋ก๊ทธ๋๋จธ์ค ์ฝ๋ฉํ ์คํธ ์ฐ์ต level2 (์ฃผ์๊ฐ๊ฒฉ) ๋ณธ๋ฌธ
๐ Coding Test/Programmers
[Python] ํ๋ก๊ทธ๋๋จธ์ค ์ฝ๋ฉํ ์คํธ ์ฐ์ต level2 (์ฃผ์๊ฐ๊ฒฉ)
ใ ใ ใ ใ 2023. 1. 19. 21:44728x90
1. ๋ฌธ์ ์ค๋ช
์ด ๋จ์๋ก ๊ธฐ๋ก๋ ์ฃผ์๊ฐ๊ฒฉ์ด ๋ด๊ธด ๋ฐฐ์ด prices๊ฐ ๋งค๊ฐ๋ณ์๋ก ์ฃผ์ด์ง ๋, ๊ฐ๊ฒฉ์ด ๋จ์ด์ง์ง ์์ ๊ธฐ๊ฐ์ ๋ช ์ด์ธ์ง๋ฅผ return ํ๋๋ก solution ํจ์๋ฅผ ์์ฑํ์ธ์.
2. ์ ํ์ฌํญ
- prices์ ๊ฐ ๊ฐ๊ฒฉ์ 1 ์ด์ 10,000 ์ดํ์ธ ์์ฐ์์ ๋๋ค.
- prices์ ๊ธธ์ด๋ 2 ์ด์ 100,000 ์ดํ์ ๋๋ค.

3. ๋ด ํ์ด
from collections import deque
def solution(prices):
answer = []
prices = deque(prices)
n_prices = len(prices)
for i in range(n_prices-1):
n = prices.popleft()
answer.append(n_prices-i-1)
for idx,j in enumerate(prices):
if n > j:
answer.pop()
answer.append(idx+1)
break
answer.append(0)
return answer
4. ๋ค๋ฅธ ์ฌ๋ ํ์ด
def solution(prices):
answer = [0] * len(prices)
for i in range(len(prices)):
for j in range(i+1, len(prices)):
if prices[i] <= prices[j]:
answer[i] += 1
else:
answer[i] += 1
break
return answer
728x90
'๐ Coding Test > Programmers' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Comments