C# - Store id value in simple array, main part is understanding question
csharp\npublic class OrderedStream\n{\n    string[] ordered;\n    int ptr;\n\n    public OrderedStream(int n)\n    {\n        ordered = new string[n + 1];\n    
```csharp\npublic class OrderedStream\n{\n    string[] ordered;\n    int ptr;\n\n    public OrderedStream(int n)\n    {\n        ordered = new string[n + 1];\n        ptr = 1;\n    }\n\n    public IList<string> Insert(int id, string value)\n    {\n        ordered[id] = value;\n        List<string> result = new List<string>();\n\n        int i = id;\n\n        if (ptr == id)\n        {                    \n            for (; i < ordered.Length; i++)\n            {\n                if (ordered[i] != null)\n                {\n                    result.Add(ordered[i]);\n                }\n\n                else\n                {\n                    break;\n                }\n            }                    \n            \n            ptr = i;\n        }\n        \n        return result;\n    }\n}\n```
[]