@@ -0,0 +1,1613 @@
+public class Solution %7B%0A    public List%3CString%3E restoreIpAddresses(String s) %7B%0A        List%3CString%3E result = new ArrayList%3CString%3E();%0A        if(s.length() %3C 4)%7B%0A            return result;%0A        %7D%0A        %0A        int p0 = (s.charAt(0) == '0')? 1: s.length()-3;%0A        for(int i = 1; i %3C= p0; i ++)%7B%0A            int num0 = Integer.parseInt(s.substring(0,i));%0A            if(num0 %3E 255)%7B%0A                break;%0A            %7D%0A            int p1 = (s.charAt(i) == '0')? i+1: s.length()-2;%0A            for(int j = i+1; j %3C= p1; j++)%7B%0A                int num1 = Integer.parseInt(s.substring(i, j));%0A                if(num1 %3E 255)%7B%0A                    break;%0A                %7D%0A                int p2 = (s.charAt(j) == '0')? j+1: s.length()-1;%0A                for(int k = j+1; k %3C= p2; k++)%7B%0A                    int num2 = Integer.parseInt(s.substring(j,k));%0A                    if(num2 %3E 255)%7B%0A                        break;%0A                    %7D%0A                    if(s.charAt(k) == '0' && k != s.length()-1)%7B%0A                        continue;%0A                    %7D%0A                    if(s.length() - k %3E 3)%7B%0A                        continue;%0A                    %7D%0A                    int num3 = Integer.parseInt(s.substring(k));%0A                    if(num3 %3E 255)%7B%0A                        continue;%0A                    %7Delse%7B%0A                        String str = num0+%22.%22+num1+%22.%22+num2+%22.%22+num3;%0A                        if(!result.contains(str))%7B%0A                            result.add(str);%0A                        %7D%0A                    %7D%0A                %7D%0A            %7D%0A        %7D%0A        return result;%0A    %7D%0A%7D

Q93 Restore IP Addresses