当前位置:网站首页>「 每日一练,快乐水题 」1108. IP 地址无效化
「 每日一练,快乐水题 」1108. IP 地址无效化
2022-06-25 04:01:00 【谁吃薄荷糖】
力扣原题:
*题目简述:
给你一个有效的 IPv4 地址 address,返回这个 IP 地址的无效化版本。
所谓无效化 IP 地址,其实就是用 “[.]” 代替了每个 “.”。
*解题思路:
- 模拟大法好
- 遍历字符串,把
.替换成[.]即可 - over
*C++代码:
class Solution {
public:
string defangIPaddr(string address) {
string ans;
for (auto c : address) {
if (c == '.') {
ans += "[.]";
} else {
ans.push_back(c);
}
}
return ans;
}
};
结果展示:

边栏推荐
- Blob page in gbase 8s
- PHP extracts and analyzes table contents, and collects bidding information
- How to screen out words related to products and eliminate invalid words accurately
- Record small knowledge points
- 重磅直播 | 相移法+多频外差之数学原理推导+实现
- Mongodb cluster
- LeetCode 劍指Offer II 091 粉刷房子[動態規劃] HERODING的LeetCode之路
- i. Max development board learning record
- Leetcode points to the leetcode road of offering II 091 house painting [dynamic planning] heroding
- Musk released humanoid robot. Why is AI significant to musk?
猜你喜欢
随机推荐
SQL injection details
php开发支付宝支付功能之扫码支付流程图
GBASE 8s的级联删除功能
Laravel document sorting 3. CSRF protection
Data import and export for gbase 8s
UCLA | generative pre training for black box optimization
i. Max development board learning record
Blob page in gbase 8s
Retrofit source code analysis
What is the storage engine and the three common database storage engines for MySQL
Laravel document sorting 2. Route related
cnpm : 无法加载文件 C:\Users\Administrator\AppData\Roaming\npm\cnpm.ps1,因为在此系统上禁止运行脚本。
Laravel document sorting 8. Middleware
Introduction to the isolation level of gbase 8s
Communication problems in parent and child components of uniapp
什么是存储引擎以及MySQL常见的三种数据库存储引擎
什么是数据持久化?
Leetcode points to the leetcode road of offering II 091 house painting [dynamic planning] heroding
Solution of gbase 8s livelock and deadlock
Basic introduction of gbase 8s blocking technology









