LeetCode
Given a string containing only digits, restore it by returning all possible valid IP address combinations.
For example:
Given
Given
"25525511135"
,
return
["255.255.11.135", "255.255.111.35"]
. (Order does not matter)
Solution:
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.
No comments:
Post a Comment