Given a string consisting of continuous integers, return all the possible valid IP addresses possible.
s = "25525511135"
answers = [“255.255.11.135”, “255.255.111.35”]
There are 2 valid IP addresses possible.
Rules for a valid IP:
1. There are 4 parts for an IP addresses.
2. Each part is a number between 0 to 255.
3. 00 is a valid IP part but 0 is valid.
4. Similarly, 025 is invalid, but 25 is valid.
We can solve this problem in multiple ways that revolve around creating the parts one by one.
In the approach below, we use backtracking, where we place the ".", as soon as we find a valid IP address part, then continue to determine whether this completes the IP address or not.
We remove the "." and place it and the next possible point.