My c++ solution
\nclass Solution {\npublic:\n    vector<string> ambiguousCoordinates(string S) {\n        vector<string> results;\n        string result;\n        S = S.substr(
```\nclass Solution {\npublic:\n    vector<string> ambiguousCoordinates(string S) {\n        vector<string> results;\n        string result;\n        S = S.substr(1, S.size() - 2);\n        for(int i = 1; i < S.size(); ++i)\n        {\n            string sLeft = S.substr(0, i);\n            if (!valid(sLeft)) continue;\n            string sRight = S.substr(i);\n            if (!valid(sRight)) continue;\n            \n            for(int k = 0; k < sLeft.size(); ++k)\n            {\n                if(sLeft[0] == \'0\')\n                {\n                    if(k > 0) break;\n                    if (sLeft.size() > 1) result = "(" + sLeft.substr(0, 1) + "." + sLeft.substr(1) + ", ";\n                    else result = "(" + sLeft + ", ";\n                }\n                else\n                {\n                    if (k && sLeft.back() != \'0\') result = "(" + sLeft.substr(0, k) + "." + sLeft.substr(k) + ", ";\n                    else if(k < 1) result = "(" + sLeft + ", ";\n                    else break;\n                }\n\n                for(int m = 0; m < sRight.size(); ++m)\n                {\n                    if(sRight[0] == \'0\')\n                    {\n                        if(m > 0) break;\n                        if (sRight.size() > 1) results.push_back(result + sRight.substr(0, 1) + "." + sRight.substr(1) + ")");\n                        else results.push_back(result + sRight + ")");\n                    }\n                    else\n                    {\n                        if (m && sRight.back() != \'0\') results.push_back(result + sRight.substr(0, m) + "." + sRight.substr(m) +")");\n                        else if(m < 1) results.push_back(result + sRight + ")");\n                        else break;\n                    }\n                }\n            }\n        }\n        return results;\n    }\n    bool valid(string s)\n    {\n        if (s.size() == 1) return true;\n        if (s[0] == \'0\' && s.back() == \'0\') return false;\n        return true;\n    }\n};\n```
[]