|
| int | hIndex (vector< int > &citations) |
| |
Definition at line 7 of file main.cpp.
◆ hIndex()
| int Solution::hIndex |
( |
vector< int > & |
citations | ) |
|
|
inline |
Definition at line 10 of file main.cpp.
11 {
12 int length = (int)citations.size();
13 if (length == 0)
14 return 0;
15
16
17
18
19
20 vector<int> count(length + 1, 0);
21 for (int citation : citations)
22 {
23 if (citation >= length)
24 count[length]++;
25 else
26 count[citation]++;
27 }
28
29
30
31
32 int total = 0;
33
34 for (int i = length; i >= 0; --i)
35 {
36 total += count[i];
37 if (total >= i)
38 return i;
39 }
40
41 return 0;
42 }
Referenced by main().
The documentation for this class was generated from the following file: