TreeMap
Code\n\nclass Solution {\n    public List<Boolean> getResults(int[][] queries) {\n        TreeMap<Integer, Integer> obstacles = new TreeMap<>(); // max up until
# Code\n```\nclass Solution {\n    public List<Boolean> getResults(int[][] queries) {\n        TreeMap<Integer, Integer> obstacles = new TreeMap<>(); // max up until block at key\n\n        List<Boolean> ans = new ArrayList<>();\n\n        for (int[] q : queries) {\n            if (q[0] == 1) { // build obstacle\n                int index = q[1];\n                Integer prev = obstacles.lowerKey(index);\n                Integer next = obstacles.higherKey(index);\n\n                if (prev == null) {\n                    obstacles.put(index, index);\n                } else {\n                    obstacles.put(index, Math.max(index - prev, obstacles.get(prev)));\n                }\n\n                prev = index;\n                while (next != null && obstacles.get(next) > obstacles.get(prev)) {\n                    obstacles.put(next, Math.max(next - prev, obstacles.get(prev)));\n                    prev = next;\n                    next = obstacles.higherKey(next);\n                }\n\n            } else { // ans query\n                int index = q[1], sz = q[2];\n                if (obstacles.containsKey(index)) { // there\'s an obstacle at queried index\n                    ans.add(obstacles.get(index) >= sz);\n                } else { // no obstacle\n                    Integer prev = obstacles.lowerKey(index);\n                    if (prev == null) {\n                        ans.add(index >= sz);\n                    } else {\n                        ans.add(Math.max(index - prev, obstacles.get(prev)) >= sz);\n                    }\n                }\n\n            }\n        }\n\n        return ans;\n\n    }\n\n}\n```
['Hash Table', 'Segment Tree', 'Java']