@@ -0,0 +1,2180 @@
+/**%0A * Created by fang on 5/3/17.%0A */%0Aimport java.util.*;%0Apublic class RestoreIPAddresses %7B%0A    public List%3CString%3E restoreIpAddresses(String s) %7B%0A        List%3CString%3E res = new LinkedList%3C%3E();%0A        if(s == null %7C%7C s.length()%3C4 %7C%7C s.length()%3E12)%7B%0A            return res;%0A        %7D%0A        String valid=%22%22;%0A        help(s,0,s.length()-1,res, 0, valid);%0A        return res;%0A    %7D%0A%0A    private void help(String s, int l, int r,List%3CString%3E res,int nums, String valid)%7B    //substring also need consider index%0A        if(nums==4 && l %3Er)%7B%0A            int length = valid.length();%0A            valid = valid.substring(0,length-1);%0A            res.add(valid);%0A            return;%0A        %7D%0A        if(l%3Er && nums != 4)%7B%0A            return;%0A        %7D%0A        int num = s.charAt(l)-'0';%0A        if(num%3E=3)%7B%0A%0A            if(l+2%3C=r+1)%7B                           //without this , index will out of range%0A                String newValid = valid+s.substring(l,l+2)+%22.%22;%0A                help(s,l+2,r,res,nums+1,newValid);%0A            %7D%0A            if(l+1%3C=r+1) %7B%0A                String newValid = valid + s.substring(l, l + 1) + %22.%22;%0A                help(s, l + 1, r, res, nums + 1, newValid);%0A            %7D%0A        %7Delse if(num%3E0)%7B%0A            if(l+3%3C=r+1 && Integer.valueOf(s.substring(l,l+3))%3C=255)%7B%0A                String newValid = valid + s.substring(l,l+3)+%22.%22;%0A                help(s,l+3,r,res,nums+1,newValid);%0A            %7D%0A            if(l+2%3C=r+1) %7B%0A                String newValid = valid + s.substring(l, l + 2) + %22.%22;%0A                help(s, l + 2, r, res, nums + 1, newValid);%0A            %7D%0A            String newValid = valid + s.substring(l,l+1)+%22.%22;%0A            help(s,l+1,r, res, nums+1,newValid);%0A        %7Delse%7B%0A            String newValid = valid+s.substring(l,l+1)+%22.%22;%0A            help(s,l+1,r,res,nums+1,newValid);%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args)%7B%0A        String s1 = %222552151135%22;%0A        RestoreIPAddresses solution = new RestoreIPAddresses();%0A        List%3CString%3E res = solution.restoreIpAddresses(s1);%0A        for(String tmp:res)%7B%0A            System.out.println(tmp);%0A        %7D%0A       // System.out.println(s1.substring(0,55));%0A    %7D%0A%7D%0A

The solution for 93