Java one loop, no need to split, 5ms, beats 100%
\nclass Solution {\n    public String fractionAddition(String expression) {\n        // initial numerator and denominator  0 = 0 / 1\n        int a = 0;\n      
```\nclass Solution {\n    public String fractionAddition(String expression) {\n        // initial numerator and denominator  0 = 0 / 1\n        int a = 0;\n        int b = 1;\n        // current numerator and denominator  c / d\n        int c = 0;\n        int d = 0;\n        // initialize \n        int sign = 1;\n        boolean isNumerator = true;\n        int len = expression.length();\n\n        for (int i = 0; i < len; i++) {\n            char ch = expression.charAt(i);\n            if (ch == \'+\') {\n                sign = 1;\n                c = 0;\n            } else if (ch == \'-\') {\n                sign = -1;\n                c = 0;\n            } else if (ch == \'/\') {\n                isNumerator = false;\n                d = 0;\n            } else {\n                if (isNumerator) {\n                    c = 10 * c + (ch - \'0\');\n                } else {\n                    d = 10 * d + (ch - \'0\');\n                    \n                    if (i == len - 1 || expression.charAt(i+1) == \'+\' || expression.charAt(i+1) == \'-\') {\n                        int e = 0;\n                        int f = 1;\n                        if (b == d) {\n                            e = a + sign * c;\n                            f = b;\n                        } else {\n                            e = a * d + sign * b * c;\n                            f = b * d;\n                        }\n\n                        // common divisor of e / f\n                        int j = gcd(e, f);\n                        a = e / j;\n                        b = f / j;\n                        // we want -1/2 rather than 1/-2\n                        if (b < 0) {\n                            a = -a;\n                            b = -b;\n                        }\n\n                        // next number should be numerator\n                        isNumerator = true;\n                    }\n                }\n            }\n        }\n        \n        return a + "/" + b;\n    }\n    \n    public static int gcd(int a, int b) {\n        while (b != 0) {\n            int t = b;\n            b = a % b;\n            a = t;\n        }\n        return a;\n    }\n}\n```
[]