ํฐ์คํ ๋ฆฌ ๋ทฐ
๋ฌธ์ ์ค๋ช
H-Index๋ ๊ณผํ์์ ์์ฐ์ฑ๊ณผ ์ํฅ๋ ฅ์ ๋ํ๋ด๋ ์งํ์ ๋๋ค. ์ด๋ ๊ณผํ์์ H-Index๋ฅผ ๋ํ๋ด๋ ๊ฐ์ธ h๋ฅผ ๊ตฌํ๋ ค๊ณ ํฉ๋๋ค. ์ํค๋ฐฑ๊ณผ1์ ๋ฐ๋ฅด๋ฉด, H-Index๋ ๋ค์๊ณผ ๊ฐ์ด ๊ตฌํฉ๋๋ค.
์ด๋ค ๊ณผํ์๊ฐ ๋ฐํํ ๋ ผ๋ฌธ nํธ ์ค, h๋ฒ ์ด์ ์ธ์ฉ๋ ๋ ผ๋ฌธ์ด hํธ ์ด์์ด๊ณ ๋๋จธ์ง ๋ ผ๋ฌธ์ด h๋ฒ ์ดํ ์ธ์ฉ๋์๋ค๋ฉด h์ ์ต๋๊ฐ์ด ์ด ๊ณผํ์์ H-Index์ ๋๋ค.
์ด๋ค ๊ณผํ์๊ฐ ๋ฐํํ ๋ ผ๋ฌธ์ ์ธ์ฉ ํ์๋ฅผ ๋ด์ ๋ฐฐ์ด citations๊ฐ ๋งค๊ฐ๋ณ์๋ก ์ฃผ์ด์ง ๋, ์ด ๊ณผํ์์ H-Index๋ฅผ return ํ๋๋ก solution ํจ์๋ฅผ ์์ฑํด์ฃผ์ธ์.
์ ํ์ฌํญ
- ๊ณผํ์๊ฐ ๋ฐํํ ๋ ผ๋ฌธ์ ์๋ 1ํธ ์ด์ 1,000ํธ ์ดํ์ ๋๋ค.
- ๋ ผ๋ฌธ๋ณ ์ธ์ฉ ํ์๋ 0ํ ์ด์ 10,000ํ ์ดํ์ ๋๋ค.
์ ์ถ๋ ฅ ์
citationsreturn
[3, 0, 6, 1, 5] | 3 |
์ ์ถ๋ ฅ ์ ์ค๋ช
์ด ๊ณผํ์๊ฐ ๋ฐํํ ๋ ผ๋ฌธ์ ์๋ 5ํธ์ด๊ณ , ๊ทธ์ค 3ํธ์ ๋ ผ๋ฌธ์ 3ํ ์ด์ ์ธ์ฉ๋์์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ ๋๋จธ์ง 2ํธ์ ๋ ผ๋ฌธ์ 3ํ ์ดํ ์ธ์ฉ๋์๊ธฐ ๋๋ฌธ์ ์ด ๊ณผํ์์ H-Index๋ 3์ ๋๋ค.
๋์ ํ์ด
def solution(citations):
totalCount = len(citations)
maxNum = max(citations)
index = []
for i in range(maxNum):
tempUp = []
tempDown = []
print("i+1์ ๊ฐ : {}".format(i+1))
for quote in citations:
print("quote : {}".format(quote))
if quote >= i+1:
tempUp.append(quote)
elif quote <= i+1:
tempDown.append(quote)
print("tempUp : {}".format(tempUp))
print("tempDown : {}".format(tempDown))
if i + 1 == len(tempUp) and (totalCount-i-1) == len(tempDown):
index.append(i+1)
return max(index)
๋๋ ์ธ์ฉํ์ (i)๋ฅผ ๊ธฐ์ค์ผ๋ก i+1์ด์์ธ ๋ ผ๋ฌธ, i+1์ดํ์ธ ๋ ผ๋ฌธ์ ๋ค๋ฅธ ๋ฆฌ์คํธ๋ก ๋ฐ๋ก ๋ด์์ ๋ฌธ์ ์ ์กฐ๊ฑด์ด ๋ง์กฑํ๋ฉด ๊ทธ i๋ฅผ ๋๋ค๋ฅธ ๋ฆฌ์คํธ์ ๋ด์ ๊ทธ ์ค์ ์ ์ผ ํฐ ๊ฐ์ ๋ฆฌํดํ๋ ๋ฐฉ์์ ์๊ฐํ๋ค.
[5,5,5,5] ์๊ฐ์ ํ ์คํธ ์ผ์ด์ค๊ฐ ์์๋๋ ๋ญ ๋ฆฌํดํ๋์ง ๋ชจ๋ฅด๊ฒ ๋ค. ๋ฌธ์ ์๋ ์ค๋ช ์ด ์๋์ด์๋๋ฐ ์ด๋ป๊ฒ ํ๋ผ๋๊ฑฐ์ง ์ฆ๋ง ์ด์ดใฑใ ์๋ค์์์ฅใ ์ด์ด์ด์ด์!!!
๋ค๋ฅธ ์ฌ๋ ํ์ด
def solution(citations):
citations.sort(reverse=True)
print(list(enumerate(citations, start=1)))
print(map(min, enumerate(citations, start=1)))
answer = max(map(min, enumerate(citations, start=1)))
print(answer)
return answer
citations = [3, 0, 6, 1, 5]
solution(citations)
๋ฌด์จ ์๋ฆฌ์ธ๊ฑฐ์ง ๋์ค์ ์ต์๊ฐ์ ์ ๊ตฌํ๋๊ฑฐ์ผ?
'(๊ตฌ)์๋ฃ๊ตฌ์กฐ&์๊ณ ๋ฆฌ์ฆ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค][Python] ๊ฐ์ฅ ํฐ ์ (2) | 2020.07.01 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค][Python] ์์์ฐพ๊ธฐ (0) | 2020.06.30 |
[ํ๋ก๊ทธ๋๋จธ์ค][Python] ๋ชจ์๊ณ ์ฌ (0) | 2020.06.30 |
ํ (Heaps) (0) | 2020.06.29 |
์ด์ง ํ์ ํธ๋ฆฌ (Binary Search Trees) (0) | 2020.06.27 |
- Total
- Today
- Yesterday
- ๊ฒ์ํ ์กฐํ
- ์จ๋ฆฌ์์ค
- ์๋ฐ
- ๊ฒ์๋ฌผ ์ญ์
- ์ ์ฒด๊ฒ์๋ฌผ ์กฐํ
- java jdk ์ค์น
- ๊ฐ๋ฐ
- mysql์ค์น
- ์ดํด๋ฆฝ์ค ํ๊ธ ์ธ์ฝ๋ฉ
- ๊ฒ์ํ๋ง๋ค๊ธฐ
- Algorithm
- ๊ฒ์๋ฌผ์กฐํ
- ๋ถํธ ์๋์์ฑ
- ๊ฒ์ํ ์ญ์
- tomcat์ค์น
- ๊ฐ๋ฐํ๊ฒฝ๊ตฌ์ถ
- ์๊ณ ๋ฆฌ์ฆ
- ๋ณ๋ช ์ฒ๋ฆฌ
- java ํ๊ฒฝ๋ณ์
- ์๋ฃ๊ตฌ์กฐ
- ์คํ๋ง๋ถํธ ์๋์์ฑ
- typeAliases
- Java
- ์ดํด๋ฆฝ์ค ์ค์น
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |