id
int64
1
3.58k
problem_description
stringlengths
516
21.8k
instruction
int64
0
3
solution_c
dict
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
1
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n map<int, int> line;\n vector<int> ans(people.size(), 0);\n\n for (auto& flower: flowers) {\n line[flower[0]]++;\n line[flower[1]+1]--;\n }\n\n...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
1
{ "code": "class Solution {\npublic:\n using int2=pair<int, int>; // (time, +1,-1)\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people)\n {\n int n = people.size();\n vector<int2> peoIdx(n);\n #pragma unroll\n for(int i=0; i<n; i++){\n peoIdx[i]={peo...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
1
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n map<int,int>mp;\n for(auto &i:flowers){\n mp[i[0]]++;mp[i[1]+1]--;\n }\n int sum = 0;\n for(auto &i:mp){\n sum += i.second;\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
1
{ "code": "class Solution {\npublic:\n \n \n int binarySearch(vector<pair<int, int>>& flowerCounts, int index) {\n if (index < flowerCounts[0].first) {\n return 0;\n }\n if (index >= flowerCounts[flowerCounts.size() - 1].first){\n return 0;\n }\n int l...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
1
{ "code": "class Solution {\npublic:\n \n \n int binarySearch(vector<pair<int, int>>& flowerCounts, int index) {\n if (index < flowerCounts[0].first) {\n return 0;\n }\n if (index >= flowerCounts[flowerCounts.size() - 1].first){\n return 0;\n }\n int l...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
1
{ "code": "class Solution {\npublic:\n // n = flowers.size(), m = people.size()\n // Difference array + Binary search \n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n map<int, int> diff;\n diff[0] = 0; // person arrives before any flower blooms\n for...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
1
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& nums, vector<int>& p)\n {\n map<int,int>mp{{0,0}};\n for(auto &it:nums)\n {\n mp[it[0]]++;\n mp[it[1]+1]--;\n }\n int sum=0;\n for(auto &[value,counter]:mp)\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
1
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n int n=flowers.size();\n int m=people.size();\n map<int,int> mp;\n for(auto &i:flowers){\n // if(i[0]==i[1]) continue;\n mp[i[0]]++;\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
1
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n sort(flowers.begin(),flowers.end());\n int n=flowers.size();\n int n1=people.size();\n \n map<int,int>m;\n for(int i=0;i<n;i++){\n if(m.find(fl...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
1
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n map<int, int> lookup;\n for (const int& time : people) {\n lookup[time];\n }\n lookup[numeric_limits<int>::max()];\n for (const vector<int>& flowe...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
1
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n map<int, int> lookup;\n for (const int& time : people) {\n lookup.emplace(time, 0);\n }\n lookup.emplace(numeric_limits<int>::max(), 0);\n for (co...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
1
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n vector<int> res(people.size());\n vector<pair<int, int>> events;\n for (const auto& flower : flowers) {\n events.emplace_back(flower[0], -1); \n even...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
1
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n vector<pair<int, int>> pl;\n for (int i = 0; i != people.size(); ++i)\n {\n pl.push_back({people[i], i});\n }\n sort(pl.begin(), pl.end(), [](pair...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
1
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n int n = flowers.size();\n vector<int> st, ed;\n for(auto it: flowers){\n st.push_back(it[0]);\n ed.push_back(it[1]);\n }\n sort(st.begi...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
1
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n vector<int> start,end;\n vector<int> ans;\n for(auto it:flowers){\n start.push_back(it[0]);\n end.push_back(it[1]);\n }\n sort(start.be...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
2
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n int n=people.size();\n vector<int>ans(n);\n vector<pair<int,int>>v;\n for(int i=0;i<n;i++){\n v.push_back({people[i],i});\n }\n vector<int>...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
2
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n std::ios::sync_with_stdio(false);\n cin.tie(0);\n vector< pair<int,int> > pos;\n vector<int> linear;\n for(int i = 0; i < flowers.size(); i++){\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
2
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n vector<int> sortedPeople(people.begin(), people.end());\n sort(sortedPeople.begin(), sortedPeople.end());\n \n sort(flowers.begin(), flowers.end());\n unorde...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
2
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n vector<int> sortedPeople(people.begin(), people.end());\n sort(sortedPeople.begin(), sortedPeople.end());\n \n sort(flowers.begin(), flowers.end());\n unorde...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
2
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n sort(flowers.begin(),flowers.end());\n map<int,int> m;\n for(int i = 0;i<flowers.size();i++){\n m[flowers[i][0]]++;\n m[flowers[i][1]+1]--;\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
2
{ "code": "using A2I = array<int, 2>;\nclass Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n map<int, int> pos_to_flag;\n for(auto& flower: flowers){\n int x = flower[0];\n int y = flower[1];\n pos_to_flag[x]++...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
2
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n\n priority_queue<int, vector<int>, greater<int>> starts;\n priority_queue<int, vector<int>, greater<int>> ends;\n map<int, int> peopleM;\n\n for(int i=0; i<people.s...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
2
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n vector<int> start;\n vector<int> end;\n int m = flowers.size();\n int n = people.size();\n for (auto f : flowers) {\n start.push_back(f[0]);\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
2
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n priority_queue<int ,vector<int> ,greater<int>>start ;\n priority_queue<int ,vector<int> ,greater<int>>end ;\n\n for(auto it : flowers)\n {\n start.push(i...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
2
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& f, vector<int>& p) {\n int l=f.size(),n=p.size();\n vector<int>ans;\n\n vector<pair<int,int>>a,b;\n\n for(auto z:f){\n a.push_back({z[0],z[1]});\n b.push_back({z[1],z[0]});\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
2
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers,\n vector<int>& people) {\n map<int, int> mp;\n for (auto i : flowers) {\n mp[i[0]]++;\n mp[i[1] + 1]--;\n }\n int ans = 0;\n for...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
2
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers,\n vector<int>& people) {\n map<int, int> flower_count;\n for (int i = 0; i < people.size(); i++) {\n flower_count[people[i]] = -1;\n }\n\n auto co...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
2
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers,\n vector<int>& people) {\n map<int, int> flower_count;\n for (int i = 0; i < people.size(); i++) {\n flower_count[people[i]] = -1;\n }\n\n auto co...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
2
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n \n // array of pairs (intervals)\n vector<int> answer(people.size(), 0);\n\n // vector of max(end) size\n // O(1) access\n // way too long to increm...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
2
{ "code": "class Solution {\npublic:\n static bool comp(pair<int, int> a, pair<int, int> b) {\n return a.first < b.first;\n }\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n vector<pair<int,int>> flowerEvents;\n for(vector<int> flower : flowers) {\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
2
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n\n\n auto comp = [](pair<int,int>a, pair<int,int>b){\n return a.first > b.first;\n };\n priority_queue<pair<int,int>,vector<pair<int,int>> ,decltype(comp)> pq;\n...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n\n int solve(vector<int>& map_vec, map<int,int>& mymap, int target){\n\n int low = 0, high = map_vec.size() - 1;\n int result = -1;\n\n while (low <= high) {\n int mid = low + (high - low) / 2;\n\n if (map_vec[mid] == target) {\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& p) {\n //line sweep algorithm\n map<int,int> mp;\n for(auto it:flowers){\n mp[it[0]]++;\n mp[it[1]+1]--;\n }\n vector<int> t,val;\n int sum=...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n map<int, int> events;\n \n for (vector<int>& vi : flowers) {\n events[vi[0]]++;\n events[vi[1]+1]--;\n }\n \n map<int, int> pref...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n map<int, int> events;\n \n for (vector<int>& vi : flowers) {\n events[vi[0]]++;\n events[vi[1]+1]--;\n }\n \n map<int, int> pref...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n unordered_map<int,int> mp;// no ordering\n vector<int> mp_key;\n #pragma unroll\n for(int p: people){\n if (mp.count(p)==0){\n mp[p]=0;\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people)\n {\n unordered_map<int,int> mp;// no ordering\n vector<int> mp_key;\n #pragma unroll\n for(int p: people){\n if (mp.count(p)==0){\n mp[p]=...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n map<int,int> diff;\n\n for (vector<int> flower: flowers){\n diff[flower[0]]++;\n diff[flower[1]+1]--;\n }\n\n vector<int> sum;\n vector...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "#define pb push_back\n#define ff first \n#define ss second\n\nclass Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& ppl) {\n int n= ppl.size();\n vector<int>res(n,0);\n map<int,int>mp;\n for( auto it : flowers){\n mp[ i...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "\nclass Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n// int n=flowers.size();\n// vector<int>start(n);\n// vector<int>last(n);\n// for(int i=0;i<n;i++){\n// start[i]=flowers[i][0];\n// ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "\nclass Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n// int n=flowers.size();\n// vector<int>start(n);\n// vector<int>last(n);\n// for(int i=0;i<n;i++){\n// start[i]=flowers[i][0];\n// ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n\n struct FlowerSort{\n bool operator()(vector<int>& a, vector<int>& b){\n return a[0] < b[0];\n }\n };\n\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n // sweep line situation\n // 1. sort int...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n\n struct FlowerSort{\n bool operator()(vector<int>& a, vector<int>& b){\n return a[0] < b[0];\n }\n };\n\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n // sweep line situation\n // 1. sort int...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n std::ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n\n sort(flowers.begin(), flowers.end());\n vector<int> starts(flowers.size());\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n int n = people.size(), sum = 0;\n vector<int> res(n);\n vector<vector<int>> vec(n);\n map<int, int> count;\n for(int i = 0 ; i < n; i++) vec[i] = {people[i],...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n priority_queue<int, std::vector<int>, std::greater<int>> q;\n sort(flowers.begin(), flowers.end());\n vector<vector<int>> queries;\n for(int i=0;i<people.size();i++...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n vector<pair<int,char>> events;\n vector<int> res;\n\n for(auto& f: flowers)\n events.push_back({f[0],'a'}), events.push_back({f[1], 'c'});\n\n for(int p:...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n int g(int v, vector<int>& xs)\n {\n return lower_bound(xs.begin(), xs.end(), v) + 1 - xs.begin();\n }\n int f[150006], s[150006], m;\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n vector<int> xs;\n for (a...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n int g(int v, vector<int>& xs)\n {\n return lower_bound(xs.begin(), xs.end(), v) + 1 - xs.begin();\n }\n int f[150006], s[150006], m;\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n vector<int> xs;\n for (a...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n // step 1: make map\n map<int,int>mp;\n for(int i=0;i<flowers.size();i++)\n {\n int x=flowers[i][0];\n int y=flowers[i][1];\n mp[x]...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n // step 1: make map\n map<int,int>mp;\n for(int i=0;i<flowers.size();i++)\n {\n int x=flowers[i][0];\n int y=flowers[i][1];\n mp[x]...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n map<int,int>m;\n for(auto it:flowers)\n {\n m[it[0]]++;\n m[it[1]+1]--;\n }\n int n=people.size();\n vector<int>ans(n,0);\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n map<int,int>m;\n for(auto it:flowers)\n {\n m[it[0]]++;\n m[it[1]+1]--;\n }\n int n=people.size();\n vector<int>ans(n,0);\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n auto cmp = [](pair<int, int> &p1, pair<int, int> &p2) { \n return p1.first > p2.first;\n };\n priority_queue<pair<int, int>, vector<pair<int, int>>, decltype(cm...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n struct compare {\n bool operator()(const pair<pair<int, int>,int>& a, const pair<pair<int, int>,int>& b) {\n if (a.first.second != b.first.second) {\n return a.first.second >b.first.second;\n } else {\n return a.first...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n bool static cmp2(vector<int> &v1,vector<int> &v2){\n return v1[1]<v2[1]; //sort based on original index;\n }\n bool static cmp1(vector<int> &v1,vector<int> &v2){\n return v1[0]<v2[0]; //sort based on people[i] (position);\n }\n vector<int> fullBloomF...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n bool static cmp2(vector<int> &v1,vector<int> &v2){\n return v1[1]<v2[1]; //sort based on original index;\n }\n bool static cmp1(vector<int> &v1,vector<int> &v2){\n return v1[0]<v2[0]; //sort based on people[i] (position);\n }\n vector<int> fullBloomF...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class FenwickTree {\npublic:\n FenwickTree(int n) : n(n) {\n tree.resize(n + 1, 0);\n }\n\n // Function to update the tree with value 'val' at index 'i'\n void update(int i, int val) {\n while (i <= n) {\n tree[i] += val;\n i += i & -i;\n }\n }\n\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n \n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n vector<int> toreturn;\n vector<vector<int>> peeps;\n for (int i = 0; i < people.size();i++) {\n toreturn.push_back(0);\n peeps.push_back({people[i],i});\n }\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n int n = flowers.size();\n map<int,int> eventChanges, bloomCount;\n for(auto flower:flowers){\n int start = flower[0];\n int end = flower[1] + 1;\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n\n map<int,int> vec;\n for(auto i:flowers){\n vec[i[0]]++;\n vec[i[1]+1]--;\n }\n\n set<pair<int,int>>st;\n int fc=0;\n int n = -...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n sort(flowers.begin(),flowers.end());\n map<int,int>mp;\n for(auto i:flowers){\n mp[i[0]]++;\n mp[i[1]+1]--;\n }\n int prev=0;\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n std::vector<pair<int, int>> peopleInds;\n for (int i = 0 ; i < people.size(); ++i) {\n peopleInds.emplace_back(people[i], i);\n }\n std::sort(peopleInds....
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n int n = people.size();\n vector<int> ans(n,0);\n map<int,int> mp;\n for(auto p:people)\n mp[p]=0;\n for(auto f:flowers){\n int s = f[0],e...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n unordered_map<int,int>mp;\n vector<int>flw;\n for(auto x:people){\n if(mp.count(x)==0){\n mp[x]=0;\n flw.push_back(x);\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n map<int, int> p; //people - flowers\n for(int i=0;i<people.size();i++)p[people[i]] = 0;\n\n map<int, int> f; //line sweep - idx to flowers\n for(auto v: flowers){\n...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n int n=flowers.size();\n int m=people.size();\n vector<pair<int,int>> p;\n for(int i=0;i<m;i++){\n p.push_back({people[i],i});\n }\n set<int...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n\n \n \n vector<pair<int,int>>vp;\n\n\n for(int i=0;i<people.size();i++)\n {\n vp.push_back({people[i],i});\n }\n\n sort(vp.begin(),vp.end());\n u...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n\n struct node {\n int t;\n int e;\n int idx;\n node(int a, int b, int c) {\n t=a;\n e=b;\n idx=c;\n }\n };\n\n static bool sorter(node *l, node *r) {\n if(l->t!=r->t) return l->t < r->t;\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& v, vector<int>& ppl) {\n int n = v.size();\n map<int,int> m,pre;\n vector<int> index;\n for (auto x : v)\n {\n m[x[0]]++;\n m[x[1] +1]--;\n index.push_back(x[...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n map<int,int> mp;\n for (auto i:flowers){\n mp[i[0]]++;\n mp[i[1]+1]--;\n }\n\n vector<int> v;\n for (auto i:people){\n v.pus...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n map<int,int> mp;\n for (auto i:flowers){\n mp[i[0]]++;\n mp[i[1]+1]--;\n }\n\n vector<int> v;\n for (auto i:people){\n v.pus...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n map<int,int> mp;\n for (auto i:flowers){\n mp[i[0]]++;\n mp[i[1]+1]--;\n }\n\n vector<int> v;\n for (auto i:people){\n v.pus...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n unordered_map<int, vector<int>>mp;\n for(int i =0; i< people.size(); i++){\n mp[people[i]].push_back(i);\n }\n priority_queue<int, vector<int>, std::grea...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n map<int,vector<int>> p;\n for(int i = 0; i < people.size(); i++) {\n p[people[i]].push_back(i);\n }\n \n vector<int> ans(people.size());\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "typedef pair<int,int> pi;\n\nclass Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n priority_queue <pi, vector <pi>, greater<>> pq;\n for( auto &flower: flowers ){\n pq.push({flower[0], -1});\n pq.push({flower[1...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n vector<int>f1;\n vector<int>f2;\n\n vector<vector<int>>p1;\n int n=flowers.size();\n for(int i=0;i<n;i++){\n f1.push_back(flowers[i][0]);\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n\n\n static bool comp(const vector<int>& a, const vector<int>& b){\n return a[1] < b[1];\n }\n\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n\n vector<vector<int>> starts(flowers);\n vector<vector<int>> ends(fl...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& nums, vector<int>& people) {\n \n int m=nums.size();\n int n=people.size();\n vector<vector<int>> arr;\n \n for(int i=0;i<n;i++){\n arr.push_back({people[i],i});\n }\...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n\n vector<int> fullBloomFlowers(vector<vector<int>>& v, vector<int>& people) {\n\nsort(v.begin(),v.end());\nfor(auto it:v) {\n for(auto a:it) {\n cout<<a<<\" \";\n }cout<<endl;\n}cout<<endl;\nint index = 0;\nint n = v.size();\npriority_queue<int,vector<int> , grea...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n \n set<int> st(people.begin(), people.end());\n int n = people.size();\n map<int, int> mp;\n for (auto it : flowers) {\n mp[it[0]]++;\n ...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n priority_queue< pair<int,int> ,vector <pair<int,int>> ,greater<pair<int,int>> > pq;\n int n=flowers.size(),m=people.size();\n int i=0,j=0;\n sort (flowers.begin(),f...
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n set<int> times;\n for (const auto &p : flowers) {\n times.insert(p[0]);\n times.insert(p[1]);\n }\n for (int i : people) {\n times....
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& people) {\n set<int> times;\n for (const auto &p : flowers) {\n times.insert(p[0]);\n times.insert(p[1]);\n }\n for (int i : people) {\n times....
2,334
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>flowers</code>, where <code>flowers[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> means the <code>i<sup>th</sup></code> flower will be in <strong>full bloom</strong> from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> (<strong>inclu...
3
{ "code": "class Solution {\npublic:\n vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& persons) {\n map<int,pair<int, vector<int>>>m;\n for(auto&i : flowers)m[i[0]].first++, m[i[1]+1].first--;\n for(int i = 0; i < persons.size(); i++)m[persons[i]].second.push_back(i);\n...
1,211
<p>Design the <code>CombinationIterator</code> class:</p> <ul> <li><code>CombinationIterator(string characters, int combinationLength)</code> Initializes the object with a string <code>characters</code> of <strong>sorted distinct</strong> lowercase English letters and a number <code>combinationLength</code> as argume...
0
{ "code": "class CombinationIterator {\npublic:\n int len;\n int mask;\n string s;\n\n CombinationIterator(string characters, int combinationLength) {\n s = characters;\n len = combinationLength;\n mask = (1 << characters.size()) - 1;\n }\n \n string next() {\n while(m...
1,221
<p>Given an integer array <strong>sorted</strong> in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> arr = [1,2,2,6,6,6,6,7,10] <strong>Output:...
0
{ "code": "class Solution {\npublic:\n int findSpecialInteger(vector<int>& arr) {\n int i,p=arr.size()/4,c=1;\n if(arr.size()==1) return arr[0];\n for(i=1;i<arr.size();i++)\n {\n if(arr[i]==arr[i-1]) \n {\n c++;\n if(c>p) break;\n }\n ...
1,221
<p>Given an integer array <strong>sorted</strong> in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> arr = [1,2,2,6,6,6,6,7,10] <strong>Output:...
0
{ "code": "class Solution {\npublic:\n int findSpecialInteger(vector<int>& arr) {\n \n for (const auto& x : {arr[arr.size() / 4], arr[arr.size() / 2], arr[arr.size() * 3 / 4]}) \n {\n if (distance(lower_bound(arr.cbegin(), arr.cend(), x),upper_bound(arr.cbegin(), arr.cend(), x)) * 4...
1,221
<p>Given an integer array <strong>sorted</strong> in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> arr = [1,2,2,6,6,6,6,7,10] <strong>Output:...
0
{ "code": "class Solution {\npublic:\n int findSpecialInteger(vector<int>& arr) {\n \n for (const auto& x : {arr[arr.size() / 4], arr[arr.size() / 2], arr[arr.size() * 3 / 4]}) \n {\n if (distance(lower_bound(arr.cbegin(), arr.cend(), x),upper_bound(arr.cbegin(), arr.cend(), x)) * 4...
1,221
<p>Given an integer array <strong>sorted</strong> in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> arr = [1,2,2,6,6,6,6,7,10] <strong>Output:...
0
{ "code": "class Solution {\npublic:\n \tint binsearchright(vector<int>& arr, int target)\n\t{\n\n //1,2,2,6,6,6,6,7,10\n\t\tint left = 0;\n\t\tint right = arr.size() - 1;\n\n\t\tint mid = 0;\n\t\tint idx = -1;\n\t\twhile (left <= right)\n\t\t{\n\t\t\tmid = left + (right - left) / 2;\n\n \n\t...
1,221
<p>Given an integer array <strong>sorted</strong> in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> arr = [1,2,2,6,6,6,6,7,10] <strong>Output:...
1
{ "code": "class Solution {\npublic:\n int findSpecialInteger(vector<int>& arr) {\n \n for (const auto& x : {arr[arr.size() / 4], arr[arr.size() / 2], arr[arr.size() * 3 / 4]}) \n {\n if (distance(lower_bound(arr.cbegin(), arr.cend(), x),upper_bound(arr.cbegin(), arr.cend(), x)) * 4...
1,221
<p>Given an integer array <strong>sorted</strong> in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> arr = [1,2,2,6,6,6,6,7,10] <strong>Output:...
1
{ "code": "class Solution {\npublic:\n int findSpecialInteger(vector<int>& arr) {\n \n for (const auto& x : {arr[arr.size() / 4], arr[arr.size() / 2], arr[arr.size() * 3 / 4]}) \n {\n if (distance(lower_bound(arr.cbegin(), arr.cend(), x),upper_bound(arr.cbegin(), arr.cend(), x)) * 4...
1,221
<p>Given an integer array <strong>sorted</strong> in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> arr = [1,2,2,6,6,6,6,7,10] <strong>Output:...
2
{ "code": "class Solution {\npublic:\n int findSpecialInteger(vector<int>& arr) {\n int count = ceil(arr.size()*1.0/4);\n int c = 1;\n int ans;\n\n for (int i=0;i<arr.size() - 1;i++) {\n if (arr[i] == arr[i+1]) {\n cout<<c<<\" \"<<arr[i]<<endl;\n ...
1,221
<p>Given an integer array <strong>sorted</strong> in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> arr = [1,2,2,6,6,6,6,7,10] <strong>Output:...
2
{ "code": "class Solution {\npublic:\n int findSpecialInteger(vector<int>& arr) {\n sort(arr.begin(),arr.end());\n int n=arr.size()/4;\n arr.push_back(-1);\n int count=1;\n \n for(int i=0;i<arr.size()-1;i++)\n {\n if(arr[i]==arr[i+1])count++;\n ...
1,221
<p>Given an integer array <strong>sorted</strong> in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> arr = [1,2,2,6,6,6,6,7,10] <strong>Output:...
2
{ "code": "class Solution {\npublic:\n int findSpecialInteger(vector<int>& arr) {\n int n=arr.size()/4;\n sort(arr.begin(),arr.end());\n\n for(int i=0;i<arr.size();i++){\n int count=0;\n for(int j=i;j<arr.size();j++){\n if(arr[i]!=arr[j]){\n ...
1,221
<p>Given an integer array <strong>sorted</strong> in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> arr = [1,2,2,6,6,6,6,7,10] <strong>Output:...
2
{ "code": "class Solution {\npublic:\n int findSpecialInteger(vector<int>& arr) {\n int tfp=floor((arr.size()*25.0)/100.0);\n int count=1;\n sort(arr.begin(),arr.end());\n for(int i=1;i<arr.size();i++){\n if(arr[i]==arr[i-1]) count++;\n else count=1;\n i...
1,221
<p>Given an integer array <strong>sorted</strong> in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> arr = [1,2,2,6,6,6,6,7,10] <strong>Output:...
2
{ "code": "class Solution {\npublic:\n int findSpecialInteger(vector<int>& arr) {\n map<int, int> mem;\n for (int i : arr) {\n if (mem.count(i) > 0) mem[i]++;\n else mem[i] = 1;\n if (mem[i] > arr.size() / 4) return i;\n }\n return 7;\n }\n};", "mem...
1,221
<p>Given an integer array <strong>sorted</strong> in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> arr = [1,2,2,6,6,6,6,7,10] <strong>Output:...
2
{ "code": "class Solution {\npublic:\n int findSpecialInteger(vector<int>& arr) {\n int n = arr.size();\n unordered_map<int, int> m;\n for(int i : arr) {\n m[i]++;\n if(4 * m[i] > n) return i;\n }\n return -1;\n \n }\n};", "memory": "17000" }
1,221
<p>Given an integer array <strong>sorted</strong> in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> arr = [1,2,2,6,6,6,6,7,10] <strong>Output:...
2
{ "code": "class Solution {\npublic:\n int findSpecialInteger(vector<int>& arr) {\n int m = arr.size() / 4;\n unordered_map<int, int> tb;\n for(auto i : arr) {\n tb[i] ++;\n if(tb[i] > m) {\n return i;\n }\n }\n return -1;\n }\n}...
1,221
<p>Given an integer array <strong>sorted</strong> in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> arr = [1,2,2,6,6,6,6,7,10] <strong>Output:...
2
{ "code": "class Solution {\npublic:\n int findSpecialInteger(vector<int>& arr) {\n double i25=arr.size()*25/100;\n unordered_map<int,int> count;\n for(int i=0;i<arr.size();i++)\n {\n count[arr[i]]++;\n if(count[arr[i]]>i25)\n return arr[i];\n }\n...