1108.IP地址无效化
链接:1108.IP地址无效化
难度:Easy
标签:字符串
简介:给你一个有效的 IPv4 地址 address,返回这个 IP 地址的无效化版本。
题解 1 - typescript
- 编辑时间:2022-03-28
- 内存消耗:5.8MB
- 编程语言:typescript
- 解法介绍:遍历。
class Solution {
   public:
    string defangIPaddr(string address) {
        string ans = "";
        for (auto &ch : address) {
            if (ch == '.')
                ans += "[.]";
            else
                ans += ch;
        }
        return ans;
    }
};