Simple Java Solution with LinkedHashMap
\npublic class RLEIterator {\n\n    long p = 0;\n    Map<Long, Integer> hm = new LinkedHashMap<>();\n\n    public RLEIterator(int[] encoding) {\n        long k 
```\npublic class RLEIterator {\n\n    long p = 0;\n    Map<Long, Integer> hm = new LinkedHashMap<>();\n\n    public RLEIterator(int[] encoding) {\n        long k = 0;\n        for (int i = 0; i < encoding.length; i += 2) {\n            k += encoding[i];\n            if (encoding[i] > 0) {\n                hm.put(k, encoding[i + 1]);\n            }\n        }\n    }\n\n    public int next(int n) {\n        p += n;\n        for (Long key : hm.keySet()) {\n            if (key >= p) {\n                return hm.get(key);\n            }\n        }\n        return -1;\n    }\n}\n\n/**\n * Your RLEIterator object will be instantiated and called as such:\n * RLEIterator obj = new RLEIterator(encoding);\n * int param_1 = obj.next(n);\n */\n```
['Java']