当前位置:网站首页>「 每日一练,快乐水题 」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;
}
};
结果展示:

边栏推荐
- Laravel document sorting 7. View
- php封装curl发送get、post请求方法,并使用
- Anaconda安装+TensorFlow安装+Keras安装+numpy安装(包含镜像和版本信息兼容问题)
- Basic use of OBS browser+ browser
- OBS Browser+浏览器的基本使用
- Synchronous and asynchronous functions (callback function, promise, generator, async/await)
- 2021.4.15 note the difference between let, const and VaR in ES6
- 深度学习——几种学习类型
- 什么是持久化?redis 持久化中的RDB和AOF是什么?
- Trigger for gbase 8s
猜你喜欢

小白学习MySQL - 统计的'投机取巧'

关于TCP连接四次握手(或者叫四次挥手)的详细总结

js的sort()函数

GBASE 8s 总体架构

单元测试覆盖率

CTF_ Web: Advanced questions of attack and defense world expert zone WP (1-4)
![L'épée leetcode fait référence au chemin leetcode de l'offre II 091 pour peindre la maison [planification dynamique] heroding](/img/ad/69fce7cf064479a0ddd477fb935de2.png)
L'épée leetcode fait référence au chemin leetcode de l'offre II 091 pour peindre la maison [planification dynamique] heroding

Anaconda安装+TensorFlow安装+Keras安装+numpy安装(包含镜像和版本信息兼容问题)

微信小程序父子组件之间传值

cnpm : 无法加载文件 C:\Users\Administrator\AppData\Roaming\npm\cnpm.ps1,因为在此系统上禁止运行脚本。
随机推荐
GBASE 8s的级联删除功能
什么是存储引擎以及MySQL常见的三种数据库存储引擎
CTF_ Web: basic 12 questions WP of attack and defense world novice zone
CTF_ Web: Learn flask template injection (SSTI) from 0
GBASE 8s的数据导入和导出
Introduction to intstream API
STM32的DMA双缓冲模式详解
A detailed summary of four handshakes (or four waves) over TCP connections
CTF_ Web: deserialization of learning notes (II) CTF classic test questions from shallow to deep
Immutable学习之路----告别传统拷贝
计算学生成绩等级(虚函数和多态)
Anaconda installation +tensorflow installation +keras installation +numpy installation (including image and version information compatibility issues)
515. 在每个树行中找最大值 / 剑指 Offer II 095. 最长公共子序列
Multithreading structure of gbase 8s
Finereport displays and hides column data according to conditions
Gbase 8s memory management
Data view for gbase 8s
Laravel document sorting 9. Blade template
Laravel document sorting 2. Route related
Laravel document sorting 11. System architecture