class Codec {
public:
// Encodes a list of strings to a single string.
string encode(vector<string>& strs) {
string encoded_string;
for(auto& str: strs) {
encoded_string += to_string(str.length()) + "/" + str;
}
return encoded_string;
}
// Decodes a single string to a list of strings.
vector<string> decode(string s) {
vector<string> res;
int i = 0;
while(i < s.size()) {
int slash = s.find("/", i);
int length = stoi( s.substr(i, slash-i) );
res.push_back( s.substr(slash+1, length) );
i = slash + 1 + length;
}
return res;
}
};
// Your Codec object will be instantiated and called as such:
// Codec codec;
// codec.decode(codec.encode(strs));