C++ 12 lines (GCD)
The initial fraction is 0/1 (n/d). We just need to read next fraction (nn/dd), normalize denominators between n/d and nn/dd (using GCD), and add/subtract the nu
The initial fraction is 0/1 (n/d). We just need to read next fraction (nn/dd), normalize denominators between n/d and nn/dd (using GCD), and add/subtract the numerator (n +/- nn). In the end, we also need to use GCD to make the resulting fraction irreducible. \n```\nint GCD(int a, int b ){ return (b == 0) ? a : GCD(b, a % b); }\nstring fractionAddition(string s) {\n    int n = 0, d = 1, p = 0, p1 = 0, p2 = 0;\n    if (s[0] != '-') s = "+" + s;\n    while (p < s.size()) {\n        for (p1 = p + 1; s[p1] != '/'; ++p1);\n        for (p2 = p1 + 1; p2 < s.size() && s[p2] != '+' && s[p2] != '-'; ++p2);\n        auto nn = stoi(s.substr(p + 1, p1 - p - 1)), dd = stoi(s.substr(p1 + 1, p2 - p1 - 1));\n        auto gcd = GCD(d, dd);\n        n = n * dd / gcd + (s[p] == '-' ? -1 : 1) * nn * d / gcd;\n        d *= dd / gcd;\n        p = p2;\n    }    \n    auto gcd = GCD(abs(n), d);\n    return to_string(n / gcd) + "/" + to_string(d / gcd);\n}\n```
[]