Java O(n) solution
\nclass Solution {\n    public String fractionAddition(String expression) {\n        expression = expression.replaceAll("-", "\\\\+-");\n        String[] fracti
```\nclass Solution {\n    public String fractionAddition(String expression) {\n        expression = expression.replaceAll("-", "\\\\+-");\n        String[] fractions = expression.split("\\\\+");\n        \n        List<int[]> fr = new ArrayList();\n        \n        int commonDenom = 1;\n        \n        for (String s : fractions) {\n            if (s.length() == 0)\n                continue;\n            \n            String[] a = s.split("/");\n            int n = Integer.parseInt(a[0]);\n            int d = Integer.parseInt(a[1]);\n            \n            if (commonDenom % d != 0)\n                commonDenom *= d;\n            fr.add(new int[]{n, d});\n        }\n        \n        int sum = 0;\n        for (int[] a : fr) {\n            sum += (a[0] * commonDenom / a[1]);\n        }\n\n        int gcdSumDenom = gcd(Math.abs(sum), commonDenom);\n        sum /= gcdSumDenom;\n        commonDenom /= gcdSumDenom;\n        \n        return "" + sum + "/" + (commonDenom == 0 ? 1 : commonDenom);\n    }\n    \n    public 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```
[]