LeetCode – 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 [“255.255.11.135”, “255.255.111.35”]. Java Solution This is a typical search problem and it can be solved by using DFS. public List<String> restoreIpAddresses(String s) { ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>(); ArrayList<String> t = new ArrayList<String>(); dfs(result, s, … Read more