🎯🔥Fraction Addition and Subtraction Simplified 🎯🔥
 # Intuition  \n\n\n# Approach\n\nA. Initial Setup:\n\n1. num is the cumulative numerator, initialized to 0.\n2. den is the cumulative denominator, initialized 
<!-- # Intuition -->\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nA. Initial Setup:\n\n1. num is the cumulative numerator, initialized to 0.\n2. den is the cumulative denominator, initialized to 1.\n\nB. Iterating through the String:\n\n1. The loop runs through the string s character by character.\n2. It detects signs (+ or -) to determine whether the current fraction is positive or negative.\n3. It then extracts the numerator (curnum) and denominator (curden) of the current fraction.\n\nC. Combining Fractions:\n\n1. The fractions are combined using the formula:\nnew_num = num \xD7 curden + curnum \xD7 den\nnew_num = num \xD7 curden + curnum \xD7 den\n\n    new_den = den \xD7 curden\n    new_den = den \xD7 curden\n\n2. This formula handles addition and subtraction by incorporating the sign into curnum.\n\nC. Simplification:\n\n1. The greatest common divisor (GCD) of the resulting numerator and denominator is calculated using __gcd.\n2. Both num and den are divided by their GCD to simplify the fraction.\n\nD. Final Output:\n\n1. The function returns the simplified fraction as a string in the form "num/den".\n2. This approach ensures that all fractions in the input string are accurately combined and returned in their simplest form.\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(log(min(a,b))) which is taken by then recursive call stack by the __gcd function. It is nearly equal to O(1).\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    string fractionAddition(string s) {\n        int n=s.length();\n        int num=0,den=1;\n        int i=0;\n        while(i<n){\n            bool isNegative=false;\n            int curnum=0,curden=0;\n            if(s[i]==\'-\' || s[i]==\'+\'){\n                if(s[i]==\'-\')\n                    isNegative=true;\n                i++;\n            }\n            while(s[i]>=48 && s[i]<=57){\n                int number=s[i]-\'0\';\n                curnum=curnum*10+number;\n                i++;\n            }\n            if(isNegative)\n                curnum*=-1;\n            i++;    //skip the "/" operator\n            while(i<n && s[i]>=48 && s[i]<=57){\n                int number=s[i]-\'0\';\n                curden=curden*10+number;\n                i++;\n            }\n            num=num*curden+curnum*den;\n            den=den*curden;\n        }\n        int gcd=abs(__gcd(num,den));\n        num/=gcd;\n        den/=gcd;\n        return to_string(num)+"/"+to_string(den);\n    }\n};\n```
['Math', 'String', 'Simulation', 'C++']