Defanging an IP Address Problem

Defanging an IP Address Problem — ExecCode Easy DSA Practice

Solve the Defanging an IP Address problem on ExecCode. Free online easy DSA practice in String. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given a valid (IPv4) IP address, return a defanged version of that IP address. Your task is to a defanged IP address replaces every period "." with "[.]". Return the required answer exactly as shown in the examples.

Examples

Input {"address": "1.1.1.1"}; Output 1[.]1[.]1[.]1. Input {"address": "255.100.50.0"}; Output 255[.]100[.]50[.]0

Constraints

The given address is a valid IPv4 address.

Practice Defanging an IP Address free on ExecCode. Browse DSA problems, topic map, and placement guides.