Easy Solution Without using Regular Expression
Intuition\nCreate 2 arrays numerator and denomenator to store all numerators and denomenators.\n\n\n# Approach\nFind lcm by multiplying all unique denomenators,
# Intuition\nCreate 2 arrays numerator and denomenator to store all numerators and denomenators.\n\n\n# Approach\nFind lcm by multiplying all unique denomenators, we can use hashSet for that.\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n```java []\nclass Solution {\n    public String fractionAddition(String expression) {\n        ArrayList<Integer> num=new ArrayList<>();\n        ArrayList<Integer> den=new ArrayList<>();\n        HashSet<Integer> denSet=new HashSet<>();\n        boolean n=true;\n        int neg=1;\n\n        for(int i=0;i<expression.length();i++)\n        {\n            char ch=expression.charAt(i);\n            if(ch==\'-\')\n                neg=-1;\n            else if(ch==\'+\')\n                neg=1;\n            else if(ch==\'/\')\n                n=false;\n            else\n            {\n                int x=ch-\'0\';\n                if(x==1 && i<expression.length()-1 && expression.charAt(i+1)==\'0\')\n                {\n                    x=10;\n                    i++;\n                }\n\n                if(n)\n                {\n                    num.add(x*neg);\n                }\n                else\n                {\n                    den.add(x);\n                    denSet.add(x);\n                    n=true;\n                }\n            }\n        }\n\n        long lcm=1;\n        for(int x:denSet)\n        {\n            lcm*=x;\n        }\n\n        long ans=0;\n        for(int i=0;i<num.size();i++)\n        {\n            ans+=lcm/den.get(i)*num.get(i);\n        }\n\n        long gcdVal=gcd(Math.abs(ans),lcm);\n\n        return ans/gcdVal+"/"+lcm/gcdVal;\n    }\n\n    public long gcd(long a, long b) {\n        while (b != 0) {\n            long temp = b;\n            b = a % b;\n            a = temp;\n        }\n        return a;\n    }\n}\n```
['Math', 'String', 'Simulation', 'Java']