Easy Java Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public String fractionAddition(String expression) {\n        ArrayList<Integer>numerator=new ArrayList<>();\n        ArrayList<Integer>denominator=new ArrayList<>();\n        for(int i=0;i<expression.length();i++){\n            char ch=expression.charAt(i);\n            int idx=i;\n            if(ch==\'/\'){\n                int val1=expression.charAt(idx-1)-\'0\';\n                if(idx-2>=0){\n                   if(expression.charAt(idx-2)-\'0\'==1){\n                    val1=10;\n                    idx--;\n                   }\n                   \n                }\n                if(idx-2>=0&&expression.charAt(idx-2)==\'-\'){\n                    val1=-val1;\n                }\n                idx=i;\n                numerator.add(val1);\n                int val2=expression.charAt(idx+1)-\'0\';\n                 if(idx+2<expression.length()){\n                    if(expression.charAt(idx+2)-\'0\'==0){\n                        val2=10;\n                    }\n                 }   \n                \n                denominator.add(val2);\n            }\n        }\n        System.out.println("numerator="+numerator);\n        System.out.println("denominator="+denominator);\n        int lcm = denominator.get(0);\n        for (int i = 1; i < denominator.size(); i++) {\n            lcm = lcm(lcm, denominator.get(i));\n        }\n        int sum=0;\n        for(int i=0;i<denominator.size();i++){\n            int fact=lcm/denominator.get(i);\n            sum+=numerator.get(i)*fact;\n        }\n        if(sum==0){\n            return sum+"/"+1;\n        }\n        boolean flag=false;\n        if(sum<0){\n            flag=true;\n            sum=-sum;\n        }\n        System.out.println("sum="+sum);\n        HashMap<Integer,Integer>map1=new HashMap<>();\n        HashMap<Integer,Integer>map2=new HashMap<>();\n         for (int i = 2; i <= Math.sqrt(sum); i += 1) {\n            // While i divides n, add i and divide n\n            while (sum % i == 0) {\n                map1.put(i, map1.getOrDefault(i, 0) + 1);\n                sum /= i;\n            }\n        }\n        if (sum > 1) {\n            map1.put(sum, map1.getOrDefault(sum, 0) + 1);\n        }\n        System.out.println("Before deleting map1="+map1);\n        for (int i = 2; i <= Math.sqrt(lcm); i += 1) {\n            // While i divides n, add i and divide n\n            while (lcm % i == 0) {\n                System.out.println("lcm="+lcm);\n                if(map1.containsKey(i)&&map1.get(i)>0){\n                   map1.put(i, map1.get(i)-1);\n                }else{\n                    map2.put(i, map2.getOrDefault(i, 0) + 1);\n                }\n                lcm/=i;\n                System.out.println("end");\n                System.out.println("lcm="+lcm);\n                System.out.println("i="+i);\n            }\n        }\n       if (lcm > 1) {\n            if (map1.containsKey(lcm) && map1.get(lcm) > 0) {\n                map1.put(lcm, map1.get(lcm) - 1);\n            } else {\n                map2.put(lcm, map2.getOrDefault(lcm, 0) + 1);\n            }\n        }\n        int prod1=1,prod2=1;\n        System.out.println("map1="+map1);\n        System.out.println("map2="+map2);\n        for (HashMap.Entry<Integer, Integer> entry : map1.entrySet()) {\n            int key = entry.getKey();\n            int value = entry.getValue();\n            prod1*=(int)Math.pow(key,value);\n        }\n        for (HashMap.Entry<Integer, Integer> entry : map2.entrySet()) {\n            int key = entry.getKey();\n            int value = entry.getValue();\n            prod2*=(int)Math.pow(key,value);\n        }\n        if(flag==true){\n            prod1=prod1*-1;\n        }\n        return prod1+"/"+prod2;\n\n    }\n    public int gcd(int a, int b) {\n        if (b == 0) {\n            return a;\n        }\n        return gcd(b, a % b);\n    }\n    public int lcm(int a, int b) {\n        return (a * b) / gcd(a, b);\n    }\n}\n```
['Java']