Loading problem...
A valid IPv4 network address is composed of exactly four numeric octets, each separated by a single period (dot). Each octet must be an integer in the range 0 to 255 (inclusive), and leading zeros are not permitted unless the octet itself is exactly 0.
Validity Rules:
"0.1.2.201" and "192.168.1.1" are valid IPv4 addresses."0.011.255.245" is invalid because 011 has a leading zero."192.168.1.312" is invalid because 312 exceeds 255."192.168@1.1" is invalid because it contains a non-digit character.You are given a string s that contains only numeric digits. Your task is to determine all possible valid IPv4 addresses that can be constructed by strategically inserting exactly three dot separators into the string.
Important constraints:
Return an array containing all valid IPv4 addresses that can be formed from the input string.
s = "25525511135"["255.255.11.135","255.255.111.35"]The string '25525511135' can be segmented into valid IPv4 addresses in two ways: • '255.255.11.135' - All four octets (255, 255, 11, 135) are valid: within range and no leading zeros. • '255.255.111.35' - All four octets (255, 255, 111, 35) are valid: within range and no leading zeros. Other segmentations like '255.2551.11.35' would create an invalid octet (2551 > 255).
s = "0000"["0.0.0.0"]The only valid segmentation is '0.0.0.0'. Each octet is exactly '0', which is valid. Segmentations like '00.0.0' are invalid because '00' has a leading zero.
s = "101023"["1.0.10.23","1.0.102.3","10.1.0.23","10.10.2.3","101.0.2.3"]The string '101023' produces five valid IPv4 addresses. Each segmentation uses all six digits exactly once, places exactly three dots, and creates four octets that are all within range [0, 255] with no improper leading zeros.
Constraints