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 | 29 | 30 | 31 |
Tags
- ํฌ๋กค๋ง
- ADP
- ๋ ๋ฆฝํ๋ณธ
- ๋ฐ์ดํฐ๋ถ์
- ์๋ํด๋ผ์ฐ๋
- ํ์ด์ฌ
- PCA
- opencv
- ๋ฐ์ดํฐ๋ถ๊ท ํ
- datascience
- t-test
- pandas
- Lambda
- ์ค๋ฒ์ํ๋ง
- ๋น ๋ฐ์ดํฐ๋ถ์๊ธฐ์ฌ
- DBSCAN
- ๋น ๋ฐ์ดํฐ
- ์ฃผ์ฑ๋ถ๋ถ์
- ๊ตฐ์งํ
- ํ ์คํธ๋ถ์
- ๋์ํ๋ณธ
- ๋ฐ์ดํฐ๋ถ์์ ๋ฌธ๊ฐ
- iloc
- LDA
- ์ธ๋์ํ๋ง
- Python
- numpy
- ADsP
- ๋ฐ์ดํฐ๋ถ์์ค์ ๋ฌธ๊ฐ
- dataframe
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