Restore IP Addresses

Description

Given a string s containing only digits, you have to return all the possible IP addresses that can be obtained from the string s in a list.

The order in which IP addresses are placed in the list is not important.

A valid IP address consists of four integers, where each integer lies within the range of 0 and 255. These integers are separated by single dots . and cannot have leading zeros.

Constraints

  • The input string s consists of digits only.
  • 4 <= s.length <= 12

Let’s review a few examples below:

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.