C++ solution with explanation
OG solution: https://leetcode.com/problems/design-an-ordered-stream/discuss/936090/C%2B%2B-Array\nFirst create a vector that will store the strings in the strea
OG solution: https://leetcode.com/problems/design-an-ordered-stream/discuss/936090/C%2B%2B-Array\nFirst create a vector that will store the strings in the stream and over which we will iterate. Resize it to n+1 because the idKey will start from 1 and not 0.\nIn the insert function, assign the value to appropriate idKey and check if the ptr is less than the stream size (because in the next step we are indexing into s to check if the value is empty at that index. Once checked that we have value, add that to return vector and go ahead, until we have some value at those indexes. \n```\nclass OrderedStream {\npublic:\n    int ptr = 1;\n    vector<string> s;\n    OrderedStream(int n) {\n        s.resize(n+1);\n    }\n    \n    vector<string> insert(int idKey, string value) {\n        vector<string> ret;\n        s[idKey] = value;\n        while(ptr<s.size() && !s[ptr].empty())\n            ret.push_back(s[ptr++]);\n        return ret;\n    }\n};\n\n/**\n * Your OrderedStream object will be instantiated and called as such:\n * OrderedStream* obj = new OrderedStream(n);\n * vector<string> param_1 = obj->insert(idKey,value);\n */\n ```\n Time complexity: O(N)\n Space complexity: O(N)
['C', 'C++']