Restore Valid IPv4 Addresses
Place three dots in a digit string to form every valid IPv4 address.
The problem
Implement Solution.restoreIpAddresses(text). text is a string of digits. Return every valid IPv4 address you can make by inserting three dots into text, without reordering, adding or removing digits. A valid address has exactly four parts, each a number from 0 to 255, and a part with more than one digit may not start with 0 ("0" is allowed, "01" is not). For example, "25525511135" gives "255.255.11.135" and "255.255.111.35". Return the addresses in any order, or an empty list if there are none. Constraints: text has 1 to 20 digits.
Starter code
class Solution:
def restoreIpAddresses(self, text):
passPublic examples
text = "25525511135"gives["255.255.11.135", "255.255.111.35"]text = "9999"gives["9.9.9.9"]text = "255255255255"gives["255.255.255.255"]
Solving it in the practice book needs an active paid plan.
Open it in the practice bookOne thought at a time.
