class Solution:
def defangIPaddr(self, address: str) -> str:
# replace
return address.replace('.', '[.]')
# def defangIPaddr(self, address: str) -> str:
# # split and join
# return '[.]'.join(address.split('.'))
# def defangIPaddr(self, address: str) -> str:
# # replace
# return re.sub('\.', '[.]', address)
# def defangIPaddr(self, address: str) -> str:
# return ''.join('[.]' if c == '.' else c for c in address)
Download Defanging an IP Address.pyLeetcode 1108 Defanging an IP Address problem solution in python3 with explanation. This is the best place to expand your knowledge and get prepared for your next interview.
Feedback is the most important part of any website.
If you have any query, suggestion or feedback, Please feel free to contact us.