class Solution {
public:
vector<string> res;
// Encodes a URL to a shortened URL.
string encode(string longUrl) {
res.push_back(longUrl);
return "http://tinyurl.com/"+to_string(res.size()-1);
}
// Decodes a shortened URL to its original URL.
string decode(string shortUrl) {
int index=shortUrl.find_last_of('/');
string temp=shortUrl.substr(index+1);
return res[stoi(temp)]; //stoi--string to int
}
};