串练习--------535.TinyURL的加密和解密

题目:点这里

代码

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));

反思

异或'^'可以对地址进行加密操作。

相关推荐
郝学胜-神的一滴32 分钟前
Effective STL 条款12:对容器线程安全性的现实期望
c语言·开发语言·c++·qt·网络协议·rpc·numpy
让我们一起加油好吗2 小时前
【数据结构】线段树详解
数据结构·c++·算法·线段树·洛谷
路灯中转站3 小时前
数据结构C语言版(什么是数据类型)
数据结构
凌冰_3 小时前
数据结构 - 队列(五)
数据结构·算法·软件工程
sul.i3 小时前
浅析 · 分治
c++
让我们一起加油好吗4 小时前
【数据结构】ST 表
数据结构·c++·算法·动态规划·洛谷·st表
敲上瘾4 小时前
Qt 常用控件:按钮、显示输入、容器与布局等
开发语言·c++·qt·qt6.3
船神丿男人4 小时前
C++ STL 入门:用 std::string 读配置,四个容易漏掉的边界
开发语言·c++
让我们一起加油好吗5 小时前
【算法刷题】LeetCode 力扣 Hot 100 刷题记录
数据结构·c++·算法·leetcode·面试·笔试
爱和冰阔落6 小时前
【Linux网络】GET 和 POST 真的只是参数位置不同吗?从 HTTP 请求方法、抓包分析到长连接与路由实战
linux·c++·http·网络编程·get与post