Posted on

Description

Submission

class OrderedStream {
    vector<string> v;
    int ptr;
public:
    OrderedStream(int n) {
        v.resize(n+2, "");
        ptr = 1;
    }
    
    vector<string> insert(int idKey, string value) {
        v[idKey] = value;
        
        vector<string> rets;
        
        
        for(; v[ptr] != ""; ptr++) {
            rets.push_back(v[ptr]);
        }
        return rets;
    }
};

/**
 * Your OrderedStream object will be instantiated and called as such:
 * OrderedStream* obj = new OrderedStream(n);
 * vector<string> param_1 = obj->insert(idKey,value);
 */

Leave a Reply

Your email address will not be published. Required fields are marked *