leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
0274.cpp (393B)
0 class Solution {
1 static int arr[5001];
3 public:
4 int hIndex(vector<int> &citations) {
5 memset(arr, 0x00, sizeof(arr));
6 for (int n : citations)
7 arr[n]++;
9 int total = 0;
10 for (int i = 5000; i >= 0; i--) {
11 total += arr[i];
12 if (total >= i) return i;
13 }
15 return -1;
16 }
17 };
19 int Solution::arr[5001] = {0};