当前位置:网站首页>Leetcode 535 encryption and decryption of tinyurl [map] the leetcode road of heroding
Leetcode 535 encryption and decryption of tinyurl [map] the leetcode road of heroding
2022-06-29 11:27:00 【HERODING23】

Their thinking :
direct map Storage url, Then use a random string +URL Serial number instead of return , As an encrypted string , Decrypt and directly obtain the sequence number to return the corresponding value that will do , The code is as follows :
class Solution {
private:
int id = 0;
unordered_map<int, string> mp;
public:
// Encodes a URL to a shortened URL.
string encode(string longUrl) {
mp[id] = longUrl;
return "noway.com/" + to_string(id);
id ++;
}
// Decodes a shortened URL to its original URL.
string decode(string shortUrl) {
int i = stoi(shortUrl.substr(10, shortUrl.size() - 10));
return mp[i];
}
};
// Your Solution object will be instantiated and called as such:
// Solution solution;
// solution.decode(solution.encode(url));
边栏推荐
- (JS) handwriting depth comparison
- 高效远程办公的基石:有效沟通 |社区征文
- How to properly manage temporary files when writing shell scripts
- 通过网上进行股票开户安全吗
- Pipeline aggregations管道聚合-Sibling-1
- Online sql to htmltable tool
- TTL串口学习型红外遥控模块可扩展成网络控制
- [3 questions per day (2)] minimum operand for generating alternate binary strings
- (JS) handwritten bind function
- Modbus RTU 协议485学习型2路红外模块
猜你喜欢
![[various * * question series] what are OLTP and OLAP?](/img/3f/48b4108d14d40212f678971c1b62bb.png)
[various * * question series] what are OLTP and OLAP?

什么?漫画居然能免费看全本了,这还不学起来一起做省钱小能手

多线程高并发服务器:3个问题

Pipeline aggregations pipeline aggregations - parent-2

What is the experience of working in an IT company in Japan?

【数字信号调制】基于 AM+FM+DSB+SSB实现信号调制解调含Matlab源码

Online sql to htmltable tool

【每日3题(3)】重新格式化电话号码

Take another picture of cloud redis' improvement path

Modbus RTU 协议485学习型2路红外模块
随机推荐
The use of variables in shell that you have to be familiar with
Data analysis method and Thinking: funnel analysis
Bs-gx-017 online examination management system based on SSM
Mysql查询表字段信息
云原生开发必备:首个通用无代码开发平台 iVX 编辑器
工具箱之 IKVM.NET 项目新进展
中科方德技术专家直播:如何基于 OpenStack、Ceph 构建私有云平台? | 第 27 期
第12周实验---基于FPGA的VGA协议实现
(JS) isnan() method determines the reason why undefined is true
Easydss is deployed on Disk C, and the video playback cannot be played normally. How to solve this problem?
重建中国科研自信——2022最新自然指数排行榜(Nature Index 2022 )公布,中国的研究产出增幅最大...
Mysql获取表信息
Ikvm Net project progress
Modbustcp protocol WiFi wireless learning single channel infrared module (round shell version)
crypto 1~5
Spark - Task 与 Partition 一一对应与参数详解
(JS) status mode
【各种**问题系列】OLTP和OLAP是啥?
When a technician becomes a CEO, what "bugs" should be modified?
MySQL 索引失效的几种类型以及解决方式