We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fe151c8 commit 9e0187fCopy full SHA for 9e0187f
scripts/algorithms/D/Defanging an IP Address/Defanging an IP Address.py
@@ -1,16 +1,5 @@
1
-class Solution {
2
-public:
3
- string defangIPaddr(string address) {
4
- string res;
5
- for(int i=0;i<address.length();i++){
6
- if(address[i]=='.'){
7
- res+="[.]";
8
-
9
- }
10
- else{
11
- res+=address[i];
12
13
14
- return res;
15
16
-};
+// Runtime: 46 ms (Top 6.11%) | Memory: 16.10 MB (Top 75.91%)
+
+class Solution:
+ def defangIPaddr(self, address: str) -> str:
+ return address.replace('.', '[.]')
0 commit comments