Advertisement
nikunjsoni

274

Jun 22nd, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int hIndex(vector<int>& citations) {
  4.         int n=citations.size();
  5.         vector<int> h(n+1, 0);
  6.         for(auto c: citations)
  7.             h[min(n,c)]++;
  8.         int ans=n;
  9.         for(int sum=h[n]; sum<ans; sum+=h[ans])
  10.             ans--;
  11.         return ans;
  12.     }
  13. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement