GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode/python/274_H-Index.py at master · qiyuangong/leetcode Expand file tree/ Copy path274_H-Index.pyMore file actions 33 lines (31 loc) · 929 Bytes / Copy path274_H-Index.pyFile metadata and controls33 lines (31 loc) · 929 Bytes 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 32 33 class Solution(object): # def hIndex(self, citations): # """ # :type citations: List[int] # :rtype: int # """ # # Sort and check the max h where the number of paper with no less than h citations # # is no less than h # citations.sort() # ls = len(citations) # h = ls # while h > 0 and citations[ls - h] < h: # h -= 1 # return h # def hIndex(self, citations): # citations.sort() # i = 0 # while i < len(citations) and citations[len(citations) - 1 - i] > i: # i += 1 # return i def hIndex(self, citations): # counting sort ls = len(citations) papers = [0] * (ls + 1) for c in citations: papers[min(ls, c)] += 1 k, s = ls, papers[ls] while k > s: k -= 1 s += papers[k] return k |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |