LeetCode 1108. Defanging an IP Address (IP 地址无效化)
题目标签:String
题目给了我们一组 ip address,让我们把 . 变成 [.],这题可以用replace,但是这样做的话,好像没意义了。所以还是走一下array,具体看code。
Java Solution:
Runtime: 0 ms, faster than 100 %
Memory Usage: 34 MB, less than 100 %
完成日期:08/01/2019
关键点:n/a
class Solution { public String defangIPaddr(String address) { char[] charsArr = address.toCharArray(); StringBuilder sb = new StringBuilder(); for(char c : charsArr) { if(c == '.') sb.append("[.]"); else sb.append(c); } return sb.toString(); } }
LeetCode 题目列表 - LeetCode Questions List
题目来源:https://leetcode.com/