Trains the technique from
LeetCode 1108Defanging an IP AddressThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
The string address is a valid IPv4 address: four groups of decimal digits joined by single dots, as in 192.168.0.1.
Return the address with every dot swapped for the three characters [.].
Example 1
Each of the three dots becomes the bracketed form and the digit groups pass through untouched.
Example 2
All four groups are a single zero, and the three dots are wrapped just the same.
Example 3
Only the dots change, so all eight digits come through exactly as they were.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def defang_i_paddr(address: str) -> str:public String defangIPaddr(String address)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.