ONLY SET used || C++
Intuition\n Describe your first thoughts on how to solve this problem. \nWhile putting a barrier on N, we check the previous barrier (say P) on the line. The ma
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWhile putting a barrier on N, we check the previous barrier (say P) on the line. The maximum size of block that 0 to N can accomodate is the max(max of block size that can be stored from 0 to P, distance from P to N).\nWe store this maximum block size in map m for every barrier N. Also we have to update if any changes are made for barriers further than N\n\n<!-- Describe your approach to solving the problem. -->\nv: result array\ns: set that stores all barriers\nm: map to store the maximum size of block that can be accomodated for each barrier\n\n# Code\n```\nclass Solution {\npublic:\n    vector<bool> getResults(vector<vector<int>>& queries) {\n        vector<bool> v;\n        set<int> s;\n        set<int>::iterator itr;\n        map<int, int> m;\n        s.insert(0);\n        for (auto& q : queries) {\n            if (q[0] == 1) {\n                auto k = s.lower_bound(q[1]);\n                k--;\n                int x = *k; // get the previous barrier P\n                m[q[1]] = max(m[x], q[1] - x); // get max block size for N\n                s.insert(q[1]); // insert current barrier in set\n                x = q[1];\n                // for further barriers, keep updating max value\n                for (itr = s.upper_bound(q[1]); itr != s.end(); itr++) {\n                    int y = max(m[x], *itr - x);\n                    if (y == m[*itr]) break;    // to save some time (if current max value is same as before than for all further barriers their max value will be unchanged)\n                    else {\n                        m[*itr] = y;    // update max value\n                        x = *itr;       // move to next barrier\n                    }\n                }\n            }\n            else {\n                auto k = s.lower_bound(q[1]);\n                k--;\n                int x = *k; // get the previous barrier\n                v.push_back(max(m[x], q[1]-x) >= q[2]);\n            }\n        }\n        return v;\n    }\n};\n```
['C++']