Simple Implementation like school maths || C++
Intuition\nThe problem requires us to evaluate an expression containing fractions, which might involve both addition and subtraction. The result must be returne
# Intuition\nThe problem requires us to evaluate an expression containing fractions, which might involve both addition and subtraction. The result must be returned as an irreducible fraction. If the fraction is an integer, it should be returned with a denominator of 1, e.g., 2 should be returned as 2/1.\n\nTo solve this, we need to:\n1. Parse the input string and extract each fraction along with its sign.\n2. Compute the sum of these fractions by finding a common denominator.\n3. Simplify the result by finding the greatest common divisor (GCD) of the numerator and denominator.\n\n# Approach\n\n1. Parse the Expression:\n    - Traverse the string expression to identify fractions and their corresponding signs.\n    - For each fraction, extract the numerator and denominator.\n2. Compute Fraction Addition:\n    - Maintain a cumulative numerator and a common denominator.\n    - For each fraction in the expression, compute the least common multiple (LCM) of the current denominator and the new fraction\u2019s denominator.\n    - Adjust the numerators according to the LCM and add/subtract them.\n3. Simplify the Result:\n    - After processing all fractions, simplify the result by dividing both the numerator and denominator by their GCD.\n    - Return the simplified fraction as a string.\n\n# Complexity\n- Time complexity:\nParsing the expression and performing GCD/LCM operations on each fraction takes $$O(n)$$, where $$n$$ is the length of the expression string.\n\n- Space complexity:\nThe space complexity is $$O(1)$$ because we only use a few extra variables for computation.\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int gcd(int a, int b) {\n        if (b == 0)\n            return a;\n        return gcd(b, a % b);\n    }\n\n    int lcm(int a, int b) {\n        return a * (b / gcd(a, b));\n    }\n\n    string fractionAddition(string expression) {\n        int numerator = 0, denominator = 1;\n        int i = 0, n = expression.size();\n\n        while (i < n) {\n            int sign = 1;\n            if (expression[i] == \'+\' || expression[i] == \'-\') {\n                if (expression[i] == \'-\') sign = -1;\n                i++;\n            }\n\n            int currentNum = 0;\n            while (i < n && isdigit(expression[i])) {\n                currentNum = currentNum * 10 + (expression[i++] - \'0\');\n            }\n            currentNum *= sign;\n\n            i++;\n\n            int currentDen = 0;\n            while (i < n && isdigit(expression[i])) {\n                currentDen = currentDen * 10 + (expression[i++] - \'0\');\n            }\n\n            int commonDen = lcm(denominator, currentDen);\n            numerator = numerator * (commonDen / denominator) + currentNum * (commonDen / currentDen);\n            denominator = commonDen;\n        }\n\n        if (numerator == 0) return "0/1";\n\n        int GCD = gcd(abs(numerator), denominator);\n        return to_string(numerator / GCD) + "/" + to_string(denominator / GCD);\n    }\n};\n\n```
['C++']