题目:点这里
代码
cpp
class Solution {
public:
// Encodes a URL to a shortened URL.
string encode(string longUrl) {
for(int i=0;i<longUrl.size();i++){
longUrl[i]^=12;
}
return longUrl;
}
// Decodes a shortened URL to its original URL.
string decode(string shortUrl) {
for(int i=0;i<shortUrl.size();i++){
shortUrl[i]^=12;
}
}
};
// Your Solution object will be instantiated and called as such:
// Solution solution;
// solution.decode(solution.encode(url));
反思
异或'^'可以对地址进行加密操作。