Common Denominators Time : Space : 12345678910111213141516171819202122using namespace std;class Fracts{ static string frac(unsigned long long n, unsigned long long d) { return "(" + to_string(n) + "," + to_string(d) + ")"; }public: static std::string convertFrac(std::vector<std::vector<unsigned long long>> &lst) { unsigned long long lcm = lst[0][1]; for(auto fraction : lst) { unsigned long long g = __gcd(fraction[1], lcm); lcm = lcm / g * fraction[1]; } string res = ""; for(auto& fraction : lst) { unsigned long long x = lcm / fraction[1]; res += frac(fraction[0] * x, lcm); } return res; }};