Problem statement

https://leetcode.com/problems/defanging-an-ip-address/

Solution

Just use replace.

Complexity

It is O(1) for time and space.

Code

class Solution:
    def defangIPaddr(self, address):
        return address.replace(".", "[.]")