Java Backtracking Approach
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\nclass Solution {\n    public List<String> ambiguousCoordinates(String s1) {\n        String s = s1.substring(1,s1.length() - 1);\n\t    boolean[] x = new boolean[2];\n\t    boolean[] y = new boolean[2];\n\t    x[0] = true;\n\t    x[1] = true;\n\t    y[0] = false;\n\t    y[1] = true;\n        List<String> list = new ArrayList<>();\n\t    func("" + s.charAt(0),s,x,y,1,list,0);\n\t    return list;\n\t}\n\t static void func(String p,String up,boolean[] x,boolean[] y,int i,List<String> list,int comma){\n\t    if(i == up.length() - 1){\n\t        if(x[0] == false && y[0] == true && y[1] == true){\n\t            String dummy = p.substring(comma) + "." + up.charAt(i);\n\t            //System.out.println(dummy);\n\t            if(isValid(dummy)){\n\t                list.add("(" + p + "." + up.charAt(i) + ")");\n\t            }\n\t        }\n\t        if(x[0] == false && y[0] == true){\n\t            String dummy = p.substring(comma) + up.charAt(i);\n\t            if(isValid(dummy)){\n\t                list.add("(" + p + up.charAt(i) + ")");\n\t            }\n\t        }\n\t        if(x[0] == true){\n\t           if(isValid(p)){\n\t            list.add("(" + p + ", " + up.charAt(i) + ")");\n\t           }\n\t        }\n\t        return;\n\t    }\n        if(x[0] == true && x[1] == true){\n            x[1] = false;\n            func(p + "." + up.charAt(i),up,x,y,i + 1,list,comma);\n            x[1] = true;\n        }\n        if(x[0] == false && y[0] == true && y[1] == true){\n            y[1] = false;\n            func(p + "." + up.charAt(i),up,x,y,i + 1,list,comma);\n            y[1] = true;\n        }\n        func(p + up.charAt(i),up,x,y,i + 1,list,comma);\n        if(x[0] == true && y[0] == false){\n            x[0] = false;\n            y[0] = true;\n            if(isValid(p)){\n                func(p + ", " + up.charAt(i),up,x,y,i + 1,list,p.length() + 2);\n            }\n            x[0] = true;\n            y[0] = false;\n        }\n\t}\n\tstatic boolean isValid(String str){\n\t    if(str.contains(".")){\n            String[] parts=str.split("\\\\.");\n            // if(parts[1].endsWith("0")) return false;\n            // if(parts[0].equals("0")) return true;\n            // if(parts[0].startsWith("0")) return false;\n            // return true;\n            if(!parts[0].equals("0") && parts[0].startsWith("0"))\n                return false;\n            else \n                return !parts[1].endsWith("0");\n        }\n        else{\n            if(str.equals("0"))\n                return true;\n            return !str.startsWith("0");\n        }\n    }\n}\n```
['Backtracking', 'Java']