C++, vector
\nclass OrderedStream {\n    vector<string> data;\n    int N;\n    int ptr;\npublic:\n    OrderedStream(int n) : data(n), N{n}, ptr{1} {\n    }\n    \n    vecto
```\nclass OrderedStream {\n    vector<string> data;\n    int N;\n    int ptr;\npublic:\n    OrderedStream(int n) : data(n), N{n}, ptr{1} {\n    }\n    \n    vector<string> insert(int id, string value) {\n        data[id-1] = move(value);\n        vector<string> ret;\n        if(ptr != id)\n            return ret;\n        while(ptr <= N) {\n            if(data[ptr-1] == "")\n                break;\n            ret.emplace_back(data[ptr-1]);\n            ++ptr;\n        }\n        return ret;\n    }\n};\n```
[]