C++ Easy Solution Explained
The idea is very simple. We continuously split the substring in 2 parts. One is our x coordinate the other is y coordinate. Now the helper function finds the nu
The idea is very simple. We continuously split the substring in 2 parts. One is our x coordinate the other is y coordinate. Now the helper function finds the number of ways we can form the x coordinate and the y coordinate, we form the final string by combining all x coordinates and y coordinates. Rest of the explanation is in code. Comment for any doubt.\n```\nclass Solution {\npublic:\n    vector <string> helper(string s)\n    {\n        vector <string> v;\n        if(s.size()<2)\n            return {s};\n        int n=s.size();\n        if(s[0]==\'0\')\n        {\n             if(s[n-1]==\'0\')\n                 return {};\n            string t=s.substr(0,1)+ \'.\' + s.substr(1); // if s[0] is 0, only possible solution is 0.xxxxx where last digit!=0\n            return {t};\n        }\n        if(s[n-1]==\'0\')\n            return {s}; // if last digit is 0, only possible solution is the string itself\n        for(int i=0;i<n-1;i++)\n        {\n            v.push_back(s.substr(0,i+1)+\'.\'+s.substr(i+1)); // \'.\' in between all substrings\n        }\n        v.push_back(s);\n        return v;\n        \n    }\n    vector<string> ambiguousCoordinates(string S) {\n        int n=S.size();\n        \n        vector <string> ans;\n        vector <string> v1,v2;\n        for(int i=1;i<n-2;i++)\n        {\n            v1.clear();\n            v2.clear();\n            v1= helper(S.substr(1,i));\n            v2= helper(S.substr(i+1,n-i-2));\n            cout<<S.substr(1,i)<<" "<<S.substr(i+1,n-i-2)<<" ";\n            if(v1.empty() || v2.empty())\n                continue;\n            for(int a=0;a<v1.size();a++)\n            {\n                for(int b=0;b<v2.size();b++)\n                {\n                    ans.push_back(\'(\'+v1[a]+\',\'+\' \'+v2[b]+\')\');\n                }\n            }\n        }\n        return ans;\n    }\n};\n```
['C']