Restore IP Addresses
A valid IP address consists of exactly four integers separated by single dots. Each integer is between 0 and 255 (inclusive) and cannot have leading zeros. Given a string s containing only digits, return all possible valid IP addresses that can be formed by inserting dots into s.

30:00

Restore IP Addresses
medium
Topics
Companies

A valid IP address consists of exactly four integers separated by single dots. Each integer is between 0 and 255 (inclusive) and cannot have leading zeros. Given a string s containing only digits, return all possible valid IP addresses that can be formed by inserting dots into s.

Example 1:
Input: "25525511135"
Output: ["255.255.11.135","255.255.111.35"]
Constraints:
  • 1s.length201 \leq s.\text{length} \leq 20

  • s consists of digits only.

Input
arr ="25525511135"
Building IP Address

___

.

___

.

___

.

___

Valid IP Addresses (0)

No valid IPs found yet

Find valid IP addresses in "25525511135"

Variables
VariableValue
s25525511135
DepthFunction Call
Stack empty
0/86