C++ || Faster than 100% || Easy Video Solution
The video solution for the below code is\nhttps://youtu.be/2Qbzv0qbebg\n\n# Code\ncpp []\nclass Solution {\npublic:\n    string fractionAddition(string s) {\n  
The video solution for the below code is\nhttps://youtu.be/2Qbzv0qbebg\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    string fractionAddition(string s) {\n        vector<int> nums;\n        vector<int> dens;\n        int sz = s.size();\n        int i = 0;\n        bool isPositive = true;\n        while(i < sz){\n            if(s[i] == \'+\' or s[i] == \'-\'){\n                if(s[i] == \'-\') isPositive = false;\n                i++;\n            }\n            int num = 0;\n            while(s[i] >= \'0\' and s[i] <= \'9\'){\n                num = num*10 + (s[i] - \'0\');\n                i++;\n            }\n            i++;\n            int den = 0;\n            while(s[i] >= \'0\' and s[i] <= \'9\'){\n                den = den*10 + (s[i] - \'0\');\n                i++;\n            }\n            if(isPositive == false) num *= -1;\n            nums.push_back(num);\n            dens.push_back(den);\n            isPositive = true;\n        }\n        int szFractions = dens.size();\n        int lcm = 1;\n        for(int i = 0 ; i < szFractions ; i++){\n            lcm = (lcm * dens[i]) / __gcd(lcm, dens[i]);\n        }\n        int numerator = 0;\n        for(int i = 0 ; i < szFractions ; i++){\n            numerator += ((lcm / dens[i]) * nums[i]);\n        }\n        if(numerator == 0) return "0/1";\n        int GCD = __gcd(numerator, lcm);\n        if(GCD < 0) GCD *= -1;\n        return to_string(numerator / GCD) + "/" + to_string(lcm / GCD);\n    }\n};\n```
['C++']