![]() |
VOOZH | about |
Given two integer arrays a[] and b[] containing two integers each representing the numerator and denominator of a fraction respectively. The task is to find the sum of the two fractions and return the numerator and denominator of the result.
Examples :
Input: a = [1, 2] , b = [3, 2]
Output: [2, 1]
Explanation: 1/2 + 3/2 = 2/1Input: a = [1, 3] , b = [3, 9]
Output: [2, 3]
Explanation: 1/3 + 3/9 = 2/3Input: a = [1, 5] , b = [3, 15]
Output: [2, 5]
Explanation: 1/5 + 3/15 = 2/5
2, 1
Time Complexity : O(log(min(a, b))
Auxiliary Space : O(1)