dry-hard impl
Intuition\n Describe your first thoughts on how to solve this problem. \nSplit string to pair combinations (1d list) - O(s length -1)\nFurther break down each p
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSplit string to pair combinations (1d list) - O(s length -1)\nFurther break down each pair to varition combinations (2d list) - O((left len -1)*(right len) -1)\n~ O(m^3) m is the length of s\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(m^3) m is the length of s\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```\nclass Solution {\n    public List<String> ambiguousCoordinates(String s) {\n        // split string to pair combinations (1d list) - O(s length -1)\n        // further break down each pair to varition combinations (2d list) - O((left len\n        // -1)*(right len) -1)\n        // ~ O(m^3) m is the length of s\n        List<String[]> pairs = new LinkedList<>();\n        for (int i = 2; i < s.length() - 1; i++) {\n            String s1 = s.substring(1, i);\n            String s2 = s.substring(i, s.length() - 1);\n            if (s1.length() > 1 && Integer.valueOf(s1) == 0 || s2.length() > 1 && Integer.valueOf(s2) == 0)\n                continue;\n            pairs.add(new String[] { s1, s2 });\n        }\n        //pairs.forEach(x -> System.out.println(Arrays.toString(x)));\n        List<String> res = new LinkedList<>();\n        for (String[] pair : pairs) {\n            List<String> left = mutate(pair[0]);\n            List<String> right = mutate(pair[1]);\n            for (String sLeft : left)\n                for (String sRight : right)\n                    res.add("(" + sLeft + ", " + sRight + ")");\n        }\n        return res;\n    }\n\n    List<String> mutate(String s) {\n        List<String> list = new LinkedList<>();\n        if (s.length() == 1 || s.charAt(0) != \'0\')\n            list.add(s);\n        for (int i = 1; i < s.length(); i++) {\n            String s1 = s.substring(0, i), s2 = s.substring(i, s.length());\n            //System.out.println(s1 + "|" + s2);\n            if (s1.length() > 1 && s1.charAt(0) == \'0\' || s2.charAt(s2.length() - 1) == \'0\')\n                continue;\n            list.add(s1 + "." + s2);\n        }\n        return list;\n    }\n\n}\n```
['Java']