Description
Given a string of digits, return all possible valid IP addresses. Each IP has four integers (0-255) separated by dots.
Examples
Input:
s = "25525511135"Output:
["255.255.11.135","255.255.111.35"]Explanation:
Two valid IP address interpretations.
Input:
s = "101023"Output:
["1.0.10.23","1.0.102.3","10.1.0.23","10.10.2.3","101.0.2.3"]Explanation:
This example demonstrates multiple valid ways to partition a 6-digit string. Each partition creates four segments where each segment is between 0-255, with no leading zeros except for single digit '0'.
Input:
s = "010010"Output:
["0.10.0.10","0.100.1.0"]Explanation:
This example highlights the leading zero constraint - segments like '01', '010', or '00' are invalid because they have leading zeros, but single '0' is valid. Only two valid IP addresses can be formed from this input.
Constraints
- •
1 ≤ s.length ≤ 20 - •
s contains only digits