Skip to content

Commit bcf32c2

Browse files
🎉 Day 11
1 parent b6ca38a commit bcf32c2

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
1. [Path Sum III](https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/550/week-2-august-8th-august-14th/3417/) ➡️ [CPP Solution](Week2/pathSum.cpp)
1818
2. [Rotting Oranges](https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/550/week-2-august-8th-august-14th/3418/) ➡️ [CPP Solution](Week2/orangesRotting.cpp)
1919
3. [Excel Sheet Column Number](https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/550/week-2-august-8th-august-14th/3419/) ➡️ [CPP Solution](Week2/titleToNumber.cpp)
20+
4. [H Index](https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/550/week-2-august-8th-august-14th/3420/) ➡️ [CPP Solution](Week2/hIndex.cpp)
2021

2122
## Where to find me? 🌟
2223
* [Website](https://akashwho.codes/)

Week2/hIndex.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public:
3+
int hIndex(vector<int>& citations) {
4+
int n = citations.size();
5+
sort(citations.begin(), citations.end());
6+
7+
for(int i = 0; i < n; ++i) {
8+
if(citations[i] >= n - i) {
9+
return n - i;
10+
}
11+
}
12+
13+
return 0;
14+
}
15+
};

0 commit comments

Comments
 (0)