Leetcode Problem 1108. Defanging an IP Address

1108. Defanging an IP Address

Leetcode Solutions

String Replacement Approach

  1. Take the input string address which represents the IPv4 address.
  2. Use the replace method of the string class to replace all occurrences of '.' with '$.]'.
  3. Return the modified string as the defanged IP address.
UML Thumbnail

Iterative Character Scanning Approach

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...