Skip to content

Commit 9e0187f

Browse files
committed
Runtime: 46 ms (Top 6.11%) | Memory: 16.10 MB (Top 75.91%)
1 parent fe151c8 commit 9e0187f

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed
Original file line numberDiff line numberDiff line change
@@ -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-
};
1+
// Runtime: 46 ms (Top 6.11%) | Memory: 16.10 MB (Top 75.91%)
2+
3+
class Solution:
4+
def defangIPaddr(self, address: str) -> str:
5+
return address.replace('.', '[.]')

0 commit comments

Comments
 (0)