Java || O (n) || Explanation and code with comments
Even though the description may not be entirely clear, paying close attention to the attached GIF will help.\n\n1) A pointer starts at 0-th position (0-based)\n
Even though the description may not be entirely clear, paying close attention to the attached GIF will help.\n\n1) A pointer starts at 0-th position (0-based)\n2) String data is inserted at K-th position (idKey minus 1)\n3) Try to move pointer all the way to right if locations are filled\n\n```\nclass OrderedStream {\n    String[] values; //For index-wise data insertion\n    int ptr = 0; //Starting position of pointer\n    \n    public OrderedStream(int n) {\n        values = new String[n];\n    }\n    \n    public List<String> insert(int idKey, String value) {\n        List<String> output = new ArrayList();\n        values[idKey - 1] = value;\n\t\t//While values[ptr] is filled, forward ptr\n        while (ptr < values.length && values[ptr] != null) {\n            output.add(values[ptr++]);\n        }\n        return output;\n    }\n}\n```
['Java']