Easy to understand Segment tree Solution
Intuition\n- max in range [0, x] in dynamicaly updated array\n- use of point update in segment tree\n\n# Approach\n- node/index of segment tree array represent 
# Intuition\n- max in range [0, x] in dynamicaly updated array\n- use of point update in segment tree\n\n# Approach\n- node/index of segment tree array represent size of gap ending at index, if obstacle exists at x\n- use of set to find just right obstacle position and just left obstacle position to find existing gap, and update gap by breaking into two gap [l, x] & [x, r]\n- if max gap ending at x >= size of block, than we can place that block in range [0, x], else not\n\n# Complexity\n- Time complexity : O(n * log(n))\n\n- Space complexity : O(n)\n\n# Code\n```\nint maxx = 50001;\n// node/index represent size of gap ending at index, if obstacle exists at x\nclass SegTree {\n    public:\n    int n;\n    vector<int> st;\n    \n    SegTree(int _size) {\n        n = _size;\n        st.resize(4 * n + 5);\n    }\n\n    void Update(int index, int low, int high, int pos, int gap) {\n        if (low == high) {\n            st[index] = gap;\n            return;\n        }\n        int mid = (low + high) / 2;\n        if (pos <= mid) {\n            Update(index * 2 + 1, low, mid, pos, gap);\n        } else {\n            Update(index * 2 + 2, mid + 1, high, pos, gap);\n        }\n        st[index] = max(st[index * 2 + 1], st[index * 2 + 2]);\n    }\n\n    int Query(int index, int low, int high, int l, int r) {\n        if (r < low || l > high) {\n            return INT_MIN;\n        }\n        if (l <= low && high <= r) {\n            return st[index];\n        }\n        int mid = (low + high) / 2;\n        int left = Query(index * 2 + 1, low, mid, l, r);\n        int right = Query(index * 2 + 2, mid + 1, high, l, r);\n        return max(left, right);\n    }\n\n    void update(int _pos, int _gap){\n        Update(0, 0, n-1, _pos, _gap);\n    }\n    int query(int l, int r){\n        return Query(0, 0, n-1, l, r);\n    }\n};\n\nclass Solution {\npublic:\n    vector<bool> getResults(vector<vector<int>>& queries) {\n        \n        SegTree seg(maxx);\n        set<int> st;\n\n        st.insert(0);\n        st.insert(maxx);\n\n        vector<bool> ans;\n\n        for(auto& q: queries){\n\n            int x = q[1];\n            // Obstacle place query\n            if(q[0] == 1){\n\n                auto it = st.lower_bound(x);\n                int r = *it;\n                int l = *(--it);\n                st.insert(x);\n                seg.update(x, x - l);\n                seg.update(r, r - x);\n\n            }\n            else{\n                int size = q[2];\n                // check query\n                bool valid = seg.query(0, x) >= size;\n                \n                // if there is no obstacle at x, there is no accounted gat [l,x] in segment tree\n                if(!valid){\n                    auto it = st.lower_bound(x);\n                    if(*it != x){\n                        int l = *(--it);\n                        valid = (x - l) >= size;\n                    }\n                }\n\n                ans.push_back(valid);\n            }\n        }\n        return ans;\n    }\n};\n```
['Segment Tree', 'C++']