1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 19:18:14 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/IP 地址无效化 [defanging-an-ip-address].html

26 lines
804 B
HTML
Raw Normal View History

2022-03-27 20:37:52 +08:00
<p>给你一个有效的 <a href="https://baike.baidu.com/item/IPv4" target="_blank">IPv4</a> 地址&nbsp;<code>address</code>,返回这个 IP 地址的无效化版本。</p>
<p>所谓无效化&nbsp;IP 地址,其实就是用&nbsp;<code>&quot;[.]&quot;</code>&nbsp;代替了每个 <code>&quot;.&quot;</code></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>address = &quot;1.1.1.1&quot;
<strong>输出:</strong>&quot;1[.]1[.]1[.]1&quot;
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>address = &quot;255.100.50.0&quot;
<strong>输出:</strong>&quot;255[.]100[.]50[.]0&quot;
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li>给出的&nbsp;<code>address</code>&nbsp;是一个有效的 IPv4 地址</li>
</ul>