[Java] Clean and Fast | Beats 100%
The solution is self explanatory.\n\n\nclass Solution {\n\n    public List<String> ambiguousCoordinates(String digits) {\n        List<String> answer = new Arra
The solution is self explanatory.\n\n```\nclass Solution {\n\n    public List<String> ambiguousCoordinates(String digits) {\n        List<String> answer = new ArrayList<>();\n        char[] digitsArr = digits.toCharArray();\n        int n = digitsArr.length;\n\n        for (int comaIdx = 2; comaIdx < n - 1; comaIdx++) {\n            String left = new String(Arrays.copyOfRange(digitsArr, 1, comaIdx));\n            String right = new String(Arrays.copyOfRange(digitsArr, comaIdx, n - 1));\n\n            List<String> leftWithPoint = addPoints(left);\n            List<String> rightWithPoint = addPoints(right);\n\n            for (String leftFloat : leftWithPoint) {\n                for (String rightFloat : rightWithPoint) {\n                    answer.add(build(leftFloat, rightFloat, true));\n                }\n            }\n        }\n\n        return answer;\n    }\n\n    private List<String> addPoints(String digits) {\n\n        List<String> answer = new ArrayList<>();\n\n        if (isValid(digits)) {\n            answer.add(digits);\n        }\n\n        char[] digitsArr = digits.toCharArray();\n        int n = digitsArr.length;\n\n        for (int pointIdx = 1; pointIdx < n; pointIdx++) {\n            String left = new String(Arrays.copyOfRange(digitsArr, 0, pointIdx));\n            String right = new String(Arrays.copyOfRange(digitsArr, pointIdx, n));\n            String floatNum = build(left, right, false);\n\n            if (isValid(floatNum)) {\n                answer.add(floatNum);\n            }\n        }\n\n        return answer;\n    }\n\n    private String build(String left, String right, boolean comaSep) {\n        StringBuilder builder = new StringBuilder();\n\n        if (comaSep) {\n            builder.append("(");\n        }\n\n        builder.append(left);\n\n        if (comaSep) {\n            builder.append(", ");\n        } else {\n            builder.append(".");\n        }\n\n        builder.append(right);\n\n        if (comaSep) {\n            builder.append(")");\n        }\n\n        return builder.toString();\n    }\n\n    private boolean isValid(String value) {\n        if (value.length() > 1 && value.charAt(1) != \'.\' && value.startsWith("0")) {\n            return false;\n        }\n\n        if (value.contains(".") && value.endsWith("0")) {\n            return false;\n        }\n\n        return true;\n    }\n}\n```
[]