题目如下:

Given a valid (IPv4) IP address, return a defanged version of that IP address.

defanged IP address replaces every period "."with "[.]".

Example 1:

  1. Input: address = "1.1.1.1"
  2. Output: "1[.]1[.]1[.]1"

Example 2:

  1. Input: address = "255.100.50.0"
  2. Output: "255[.]100[.]50[.]0"

Constraints:

  • The given address is a valid IPv4 address.

解题思路:这个题目是来搞笑的吗?

代码如下:

  1. class Solution(object):
  2. def defangIPaddr(self, address):
  3. """
  4. :type address: str
  5. :rtype: str
  6. """
  7. return address.replace('.','[.]')

【leetcode】1108. Defanging an IP Address的更多相关文章

  1. 【Leetcode_easy】1108. Defanging an IP Address

    problem 1108. Defanging an IP Address solution: class Solution { public: string defangIPaddr(string ...

  2. LeetCode 1108. Defanging an IP Address (IP 地址无效化)

    题目标签:String 题目给了我们一组 ip address,让我们把 . 变成 [.],这题可以用replace,但是这样做的话,好像没意义了.所以还是走一下array,具体看code. Java ...

  3. [LeetCode] 1108. Defanging an IP Address

    Description Given a valid (IPv4) IP address, return a defanged version of that IP address. A defange ...

  4. 【LeetCode】468. Validate IP Address 解题报告(Python)

    [LeetCode]468. Validate IP Address 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: h ...

  5. 【LeetCode】306. Additive Number 解题报告(Python)

    [LeetCode]306. Additive Number 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http: ...

  6. 【LeetCode】831. Masking Personal Information 解题报告(Python)

    [LeetCode]831. Masking Personal Information 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzh ...

  7. 【LeetCode】Minimum Depth of Binary Tree 二叉树的最小深度 java

    [LeetCode]Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum dept ...

  8. 【Leetcode】Pascal's Triangle II

    Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3 ...

  9. 53. Maximum Subarray【leetcode】

    53. Maximum Subarray[leetcode] Find the contiguous subarray within an array (containing at least one ...

随机推荐

  1. windows环境下PostgreSQL的安装

    1.首先在如下链接下载PostgreSQL的压缩包,我这里下载的是postgresql-12.1-1-windows-x64-binaries.zip. https://www.enterprised ...

  2. 【ABAP系列】SAP ABAP 关于四舍五入算法

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 关于四舍五入算 ...

  3. python下对mysql数据库的链接操作

    参考网址: https://blog.csdn.net/guofeng93/article/details/53994112 https://blog.csdn.net/Chen_Eris/artic ...

  4. Java本周总结1

    这两周我上认真的课应该就是李老师的课了/ 第一周主要跟我们讲述了java的发展史何java开发环境的搭建,带领我们走进了java,李老师的精彩讲述让我们对Java有了深刻的认识/. jdk下载安装包我 ...

  5. [DS+Algo] 004 栈、队列及其代码实现

    1. Stack FILO (FirstInLastOut) 的链表结构 在程序编译环境上使用较多 常用操作 push pop peek is_empty size Python 代码示例 class ...

  6. 解决org.apache.subversion.javahl.ClientException的方法【】

    重新刷新项目,配置项目,总是报“The project was not built due to "org.apache.subversion.javahl.ClientException” ...

  7. vue element 导出 分页数据的excel表格

    1.安装相关依赖 npm install --save xlsx file-saver 2.导入相关插件 在组建头部导入相关插件 const FileSaver = require("fil ...

  8. soot学习历程---(1)

    今天看了soot生成手册的部分内容,简单摘录一下 Scene 表示分析所处的完整环境,可以借此设置application class(用sootclass),主类(main),point-to和cal ...

  9. 列表、元组和range

    小知识点 s = " 5 " print(int(s)) print(s.replace(" ","")) 结果: 5 5 id()#获取对 ...

  10. C#操作电脑多显示器设置

    电脑多显示器设置 第一种方式 通过使用api函数SetDisplayConfig来设置.这种方式在某些电脑中设置有几率会导致电脑黑屏 使用代码如下: private const uint SDC_AP ...