Simple commented code in C++
\nclass Solution {\npublic:\n    vector<string>fun(string str)\n    {\n        vector<string>ans;\n        int n = str.length();\n        if(n == 1)\n        {\
```\nclass Solution {\npublic:\n    vector<string>fun(string str)\n    {\n        vector<string>ans;\n        int n = str.length();\n        if(n == 1)\n        {\n            return {str};\n        }\n        // cases like "123"\n        if(str[0] != \'0\')\n        {\n            ans.push_back(str);\n        }\n        \n        if(str[0] == \'0\')\n        {\n            // cases like "0110"\n            if(str.back() == \'0\')\n            {\n                return {};\n            }\n            // cases like "011"\n            return {"0." + str.substr(1)};\n        }\n        \n        // for cases like 123 -- final vector would be {123, 1.23, 12.3}, but\n        // for cases like 120 -- final vector would be {120} and not {120, 1.20, 12.0} as 1.20 and 12.0 are invalid \n        if(str.back() != \'0\')\n        {\n                 for(int i = 1; i < n; i++)\n                    {\n                        string first = str.substr(0, i);\n                        string second = str.substr(i);\n                        ans.push_back(first + "." + second);\n                    }   \n        }\n        return ans;\n    }\n    vector<string> ambiguousCoordinates(string s) \n    {\n        vector<string>ans;\n        // removing parenthesis\n        string str = s.substr(1, s.length() - 2);\n        int n = str.length();\n        \n        for(int i = 1; i < n; i++)\n        {\n            string first = str.substr(0, i);\n            string second = str.substr(i);\n            \n            vector<string>for_first = fun(first);\n            vector<string>for_second = fun(second);\n            \n            for(int i  = 0; i < for_first.size(); i++)\n            {\n                for(int j = 0; j < for_second.size(); j++)\n                {\n                    ans.push_back("(" + for_first[i] + ", " + for_second[j] + ")");\n                }\n            }\n        }\n        return ans;\n    }\n};\n```
[]