728x90
1.문제(원본)
Given a valid (IPv4) IP address, return a defanged version of that IP address.
A defanged IP address replaces every period "." with "[.]".
Example 1:
Input: address = "1.1.1.1" Output: "1[.]1[.]1[.]1"
Example 2:
Input: address = "255.100.50.0" Output: "255[.]100[.]50[.]0"
Constraints:
- The given address is a valid IPv4 address.
2.문제
특정 문자를 다른 형태로 변환해서 새로운 문자열을 만든다
3.나의 생각
class Solution {
func defangIPaddr(_ address: String) -> String {
var result = ""
result = address.replacingOccurrences(of: ".", with: "[.]")
print(result)
return result
}
}
마무리
언어 : Swift
728x90
'알고리즘 > 해결' 카테고리의 다른 글
LeetCode977. Squares of a Sorted Array (0) | 2020.01.26 |
---|---|
LeetCode709. To Lower Case (0) | 2020.01.26 |
LeetCode 905. Sort Array By Parity (0) | 2020.01.19 |
LeetCode 1207. Unique Number of Occurrences (0) | 2020.01.19 |
LeetCode 1281. Subtract the Product and Sum of Digits of an Integer (0) | 2020.01.13 |