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

边栏推荐
- NFT insider 63: the sandbox reached a cooperation with Time magazine, and YGG established Spain's subdao
- Smart contract learning materials
- Blob page in gbase 8s
- sql_ mode=only_ full_ group_ By's pit
- UCLA | 用于黑盒优化的生成式预训练
- Basic use of OBS browser+ browser
- 单元测试覆盖率
- GBASE 8s 索引R树
- OOP栈类模板(模板+DS)
- Leetcode points to the leetcode road of offering II 091 house painting [dynamic planning] heroding
猜你喜欢

GBASE 8s 索引B+树

CTF_ Web: Advanced questions of attack and defense world expert zone WP (15-18)

LabVIEW开发气体调节器

UCLA | generative pre training for black box optimization

CTF_ Web:8-bit controllable character getshell
三角形类(构造与析构)

【esp32学习之路6——flash加密】

CTF_ Web: basic 12 questions WP of attack and defense world novice zone
![LeetCode 劍指Offer II 091 粉刷房子[動態規劃] HERODING的LeetCode之路](/img/ad/69fce7cf064479a0ddd477fb935de2.png)
LeetCode 劍指Offer II 091 粉刷房子[動態規劃] HERODING的LeetCode之路

关于TCP连接四次握手(或者叫四次挥手)的详细总结
随机推荐
GBase 8s的封锁技术的基本介绍
GbASE 8s中的Blob 页(Blobspace page)
CTF_ Web: advanced problem WP (5-8) of attack and defense world expert zone
STM32的DMA双缓冲模式详解
Office macro virus bounce shell experiment
Sourcetree pulls the code and prompts to fill in authentic, but the configuration cannot change the user
Introduction to intstream API
Xiaobai learns MySQL - Statistical 'opportunism'
Cnpm: unable to load file c:\users\administrator\appdata\roaming\npm\cnpm PS1 because running scripts is prohibited on this system.
GBASE 8s活锁、死锁问题的解决
js的arguments
《牛客刷verilog》Part I Verilog快速入门
使用文本分析识别一段文本中的主要性别
CTF_ Web: deserialization learning notes (I) classes and objects in PHP
Laravel document sorting 3. CSRF protection
CTF_ Variable coverage in web:php
Trigger for gbase 8s
深度学习——几种学习类型
Synchronous and asynchronous functions (callback function, promise, generator, async/await)
kenlm