Valid Ip Addresses

Given a string containing only digits, restore it by returning all possible valid IP address combinations.

A valid IP address must be in the form of A.B.C.D, where A,B,C and D are numbers from 0-255. The numbers cannot be 0 prefixed unless they are 0.

Example:

Given “25525511135”,

return [“255.255.11.135”, “255.255.111.35”]. (Make sure the returned strings are sorted in order)

Interview Code Editor
Hints
  • Solution Approach
  • Complete Solution
2559 successful submissions.
Asked In:
  • Amazon
Click here to jump start your coding interview preparation