93_Restore IP Address
Last updated
Last updated
[Medium]
Given a string containing only digits, restore it by returning all possible valid IP address combinations.
Example:
Idea:
Loop over all possible placements of three periods, and check if all four corresponding substring are between 0 and 255.
If a substring has length larger than 1 and starts with 0, this substring is invalid.
Time Complexity: where n is the length of input string.
Space Complexity: No extra space needed except the output.