Skip to content

Commit b971000

Browse files
authoredOct 11, 2023
2251. Number of Flowers in Full Bloom (HARD)
1 parent 3f26bd6 commit b971000

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
 
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//.................Leetcode Hard...................//
2+
/// 2D Array
3+
Class Solution {
4+
public:
5+
vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {
6+
vector<int> start, end;
7+
for (auto& t : flowers)
8+
start.push_back(t[0]), end.push_back(t[1]);
9+
sort(start.begin(), start.end());
10+
sort(end.begin(), end.end());
11+
vector<int> res;
12+
for (int t : people) {
13+
int started = upper_bound(start.begin(), start.end(), t) - start.begin();
14+
int ended = lower_bound(end.begin(), end.end(), t) - end.begin();
15+
res.push_back(started - ended);
16+
}
17+
return res;
18+
}
19+
};

0 commit comments

Comments
 (0)
Please sign in to comment.