[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/python] ์ •๋ ฌ : H-index

2021. 7. 1. 16:34

๋ฌธ์ œ ์„ค๋ช…

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ํšŒ ์ดํ•˜์ž…๋‹ˆ๋‹ค.

 

์ •๋‹ต

def solution(citations):
    if max(citations) == 0:
        return 0

    citations.sort()
    for i in range(len(citations)-1, 0, -1):
        if citations[i-1] != citations[i]:
            for h in range(citations[i], citations[i-1], -1):
                if len(citations)-i >= h:
                    return h
    for h in range(citations[0], -1, -1):
                if len(citations) >= h:
                    return h

๋‹ค๋ฅธ ์‚ฌ๋žŒ ํ’€์ด

def solution(citations):
    citations = sorted(citations)
    for i in range(len(citations)):
        if citations[i] >= len(citations)-i:
            return len(citations)-i
    return 0
728x90

BELATED ARTICLES

more