c++ cartesian product (faster than 100%)
\nclass Solution {\nprivate:\n    bool Prefix(string s)\n    {\n        int n=(int)s.length();\n        if(n==1) return true;\n        if(s[0]==\'0\') return fa
```\nclass Solution {\nprivate:\n    bool Prefix(string s)\n    {\n        int n=(int)s.length();\n        if(n==1) return true;\n        if(s[0]==\'0\') return false;\n        return true;\n    }\n    bool Suffix(string s)\n    {\n        int n=(int)s.length();\n        if(s[n-1]==\'0\') return false;\n        return true;\n    }\n    vector<string> generate(string s)\n    {\n        vector<string> g;\n        int n=(int)s.length();\n        if(Prefix(s)) g.push_back(s);\n        for(int i=1;i<n;i++)\n        {\n            string left=s.substr(0,i);\n            string right=s.substr(i);\n            if(Prefix(left)==true and Suffix(right)==true){\n                g.push_back(left+"."+right);\n            }\n        }\n        return g;\n    }\npublic:\n    vector<string> ambiguousCoordinates(string str) {\n        vector<string> sol;\n        string s=str.substr(1,str.length()-2);\n        int n=(int)s.length();\n        \n        for(int i=1;i<n;i++)\n        {\n            vector<string> left=generate(s.substr(0,i));\n            vector<string> right=generate(s.substr(i));\n            for(auto l:left)\n            {\n                for(auto r:right) sol.push_back("("+l+", "+r+")");\n            }\n        }\n        return sol;\n    }\n};\n\n```
['C']