Sunday, January 19, 2014

Restore IP Addresses (Java)


Given a string containing only digits, restore it by returning all possible valid IP address combinations.
For example:
Given "25525511135",
return ["", ""]. (Order does not matter)

DFS to combine each possible result, meanwhile skip all impossible combination for result, such as
rest letters in s can not be more than 3* rest parts and rest letters can not be less than rest parts.