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
- ๋ฐ์ดํฐ๋ถ์์ ๋ฌธ๊ฐ
- ์ฃผ์ฑ๋ถ๋ถ์
- ๊ตฐ์งํ
- ๋ฐ์ดํฐ๋ถ์์ค์ ๋ฌธ๊ฐ
- ์ค๋ฒ์ํ๋ง
- ๋ฐ์ดํฐ๋ถ๊ท ํ
- PCA
- ๋ ๋ฆฝํ๋ณธ
- ํ์ด์ฌ
- opencv
- ๋ฐ์ดํฐ๋ถ์
- ๋์ํ๋ณธ
- ์ธ๋์ํ๋ง
- Lambda
- ๋น ๋ฐ์ดํฐ
- ํฌ๋กค๋ง
- ๋น ๋ฐ์ดํฐ๋ถ์๊ธฐ์ฌ
- LDA
- ํ ์คํธ๋ถ์
- t-test
- iloc
- ADP
- DBSCAN
- numpy
- dataframe
- ADsP
- datascience
- pandas
- Python
- ์๋ํด๋ผ์ฐ๋
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 ์ดํ์ ๋๋ค.
![](https://blog.kakaocdn.net/dn/d6R73G/btrWLwVkR6U/IFkadklPC5ph48iz5DB8j0/img.png)
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