Easy to understand C++ code 🔥🔥
\n\n\n# Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) 
\n\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    string fractionAddition(string s) {\n        string res;\n        int lcm1=1;\n        vector<int> denom;\n        for(int i=0;i<s.length()-1;i++){\n            if(s[i]==\'/\'){\n                if(s[i+1]==\'1\' && s[i+2]==\'0\'){\n                    lcm1= lcm(10,lcm1);\n                    i+=2;\n                }else{\n                    lcm1 = lcm(lcm1,int(s[i+1])-48);\n                    i++;\n                }\n            }\n        }\n\n        int sum = 0;\n        int curr = 0;\n\n        for(int i = 0; i<s.size()-1; i++)\n        {\n            int mul = 1;\n            if(s[i] == \'/\'){\n                if(i-2 >= 0 && s[i-1] == \'0\' && s[i-2] == \'1\'){\n                    s[i+1] == \'1\' && s[i+2] == \'0\' ? mul = (lcm1/10) : mul = (lcm1/(int(s[i+1])-48));   \n                    curr = 10*mul;\n                }\n                else{\n                    s[i+1] == \'1\' && s[i+2] == \'0\' ? mul = (lcm1/10) : mul = (lcm1/(int(s[i+1])-48)); \n                    curr = ( (int(s[i-1]) )-48)*mul;\n                }\n           \n                 i-2>= 0 && s[i-2] == \'-\' || i-3>=0 && s[i-3] == \'-\' ? sum -= curr : sum += curr;\n          \n            }\n        }\n        \n        int k = 2;\n\n        while(k<10){\n            if (sum%k == 0 && lcm1%k == 0){\n                sum /= k;\n                lcm1 /= k;\n            }\n            else {\n                k++;\n            }\n        }\n        \n\n        string result = to_string(sum)+"/"+to_string(lcm1);\n        return result;\n    }\n};\n```
['Math', 'String', 'C++']