Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H-Index #491

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
h-index added in cpp
PurvalBhude committed Sep 15, 2024
commit 42a223d77c12363def300b99efb6c6ebde45689e
37 changes: 37 additions & 0 deletions C++/H-Index.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* medium difficulty */

class Solution{
public:
int hIndex(vector<int> &citations)
{
int n = citations.size();
int mpp[1001] = {0};

for (int i = 0; i < n; i++)
{
if (citations[i] > 1000)
{
mpp[1000]++;
}
else
{
mpp[citations[i]]++;
}
}

for (int i = 999; i >= 0; i--)
{
mpp[i] += mpp[i + 1];
}

for (int i = 1000; i >= 0; i--)
{
if (mpp[i] >= i)
{
return i;
}
}

return 0;
}
};
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -147,7 +147,8 @@ Check out ---> [Sample PR](https://github.com/codedecks-in/LeetCode-Solutions/pu
| 1512 | [Number of Good Pairs](https://leetcode.com/problems/number-of-good-pairs/) | [Java](./Java/Number-of-Good-Pairs.java) | O(N^2) | O(1) | Easy | Array |
| 162 | [Find Peak element](https://leetcode.com/problems/find-peak-element/) | [javascript](https://github.com/codedecks-in/LeetCode-Solutions/blob/master/JavaScript/findPeakElement.js) | o(Logn) | O(1) | Medium | Array |
| 54 | [Spiral Matrix](https://leetcode.com/problems/spiral-matrix/) | [C++](./C++/Spiral-matrix.cpp) | O(M\*N) | O(M\*N) | Medium | Array |
| 238 | [Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self/) | [C++](./C++/238.Product_of_array_except_self) | O(N) | O(N) | Medium | Array |
| 238 | [Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self/) | [C++](./C++/238.Product_of_array_except_self) | O(N) | O(N) | Medium | Array ||
274 | [H-Index](https://leetcode.com/problems/h-index) | [C++](./C++/H-Index.cpp) | O(n) | O(1) | Medium | Array | |


<br/>
@@ -515,6 +516,7 @@ DISCLAIMER: This above mentioned resources have affiliate links, which means if
| [Shrimadh V Rao](https://github.com/Shrimadh) <br> <img src="https://avatars.githubusercontent.com/u/64469917?v=4" width="100" height="100"> | India | C++ | [GitHub](https://github.com/Shrimadh)
| [Shreyas Shrawage](https://github.com/shreyventure) <br> <img src = "https://avatars.githubusercontent.com/u/55741087?v=4" width="100" height="100"> | India | Python | [CodeChef](https://www.codechef.com/users/shreyventure)<br/>[LeetCode](https://leetcode.com/shreyventure/)<br/>[HackerRank](https://www.hackerrank.com/shreyas_shrawage)
| [Surbhi Mayank](https://github.com/surbhi2408) <br> <img src="https://avatars.githubusercontent.com/u/58289829?s=400&u=68fd396819b927ec4d8820d87d6d1e311c3abd01&v=4" width="100" height="100"> | India | C++ | [GitHub](https://github.com/surbhi2408)
| [Purval Bhude](https://github.com/PurvalBhude) <br> <img src="https://avatars.githubusercontent.com/u/143245454?s=96&v=4" width="100" height="100"> | India | C++ | [Linkedin](https://www.linkedin.com/in/purvalbhude)<br/>[LeetCode](https://leetcode.com/Purval_Bhude/)<br/>[Github](https://github.com/PurvalBhude)
<div align="right">
<b><a href="#algorithms">⬆️ Back to Top</a></b>
</div>