/LeetCode-1108-Defanging-an-IP-Address

LeetCode Problem 1108. Defanging an IP Address - The task is to create a defanged version of a given IPv4 address by replacing each period "." with "[.]". The goal is to modify the address format while preserving its validity.

Primary LanguageJava

LeetCode Practice (Day 15)

Achievements

Leetcode-copy.jpg

About the problem

  • Problem Number : 1108
  • Problem Name : Defanging an IP Address
  • Problem difficulty : Easy (88.87%)🟢
  • Programming language used - Java

Problem

Given a valid (IPv4) IP address, return a defanged version of that IP address.

A defanged IP address replaces every period "." with "[.]".

Example 1:

Input: address = "1.1.1.1"
Output: "1[.]1[.]1[.]1"

Example 2:

Input: address = "255.100.50.0"
Output: "255[.]100[.]50[.]0"

Constraints:

  • The given address is a valid IPv4 address.

Approach Explanation

This is just too easy. Just look at the code then you can understand 😶

If you have suggestions for improvement or would like to contribute to this solution, feel free to create a pull request. 🙌😇