We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c5101c3 commit 4fb80c4Copy full SHA for 4fb80c4
Easy/1108.DefanginganIPAddress(join).py
@@ -0,0 +1,22 @@
1
+"""
2
+ Given a valid (IPv4) IP address, return a defanged version of that IP address.
3
+ A defanged IP address replaces every period "." with "[.]".
4
+
5
+ Example:
6
+ Input: address = "1.1.1.1"
7
+ Output: "1[.]1[.]1[.]1"
8
9
+ Constraints:
10
+ - The given address is a valid IPv4 address.
11
12
+#Difficulty: Easy
13
+#62 / 62 test cases passed.
14
+#Runtime: 64 ms
15
+#Memory Usage: 13.9 MB
16
17
+#Runtime: 64 ms, faster than 6.22% of Python3 online submissions for Defanging an IP Address.
18
+#Memory Usage: 13.9 MB, less than 100.00% of Python3 online submissions for Defanging an IP Address.
19
20
+class Solution:
21
+ def defangIPaddr(self, address: str) -> str:
22
+ return '[.]'.join(address.split('.'))
0 commit comments