Java Straightforward Solution!
Well, the problem statement is not very clear even there is a GIF, although I work it out. The problem statement makes it feel as a medium problem, I guess. \n\
Well, the problem statement is not very clear even there is a GIF, although I work it out. The problem statement makes it feel as a medium problem, I guess. \n\nBasically, the idea is that you need to return a longest list that start at index of ptr. if ptr is not pointing an element, you need to return a empty list.\n```\nclass OrderedStream {\n    int ptr;\n    String[] res;\n    \n    public OrderedStream(int n) {\n        ptr = 0;\n        res = new String[n];\n    }\n    \n    public List<String> insert(int id, String value) {\n        List<String> list = new ArrayList<>();\n        \n        res[id - 1] = value;\n        while (ptr < res.length && res[ptr] != null) {\n            list.add(res[ptr]);\n            ptr++;\n        }\n        \n        return list;\n    }\n}\n```
['Java']