Company: Trilogy Innovations Sde intern Oncampus_17july

Difficulty: easy

Problem Statement

Your task is to find the sum of two fractions, expressed in the form x/y and u/v , where x , y , u and v are four integers. Compute their sum and reduce it to its lowest indivisible state A/B . For example: 2/6+2/6 equals 4/6 , which should be reduced to 2/3 . 7/10+13/10 equals 20/10 , which should be reduced to 2/1 . Note that the denominator is always printed, even when it reduces to 1 . You are given an array of strings, which contains several expressions in the form "x/y+u/v" . Print one line per expression, where the i th line is the result for the i th expression in the form "A/B" . Example For fractions = ["2/6+2/6", "7/10+13/10"] , the output should be ["2/3", "2/1"] . Input Format The first line contains a single integer n , the number of expressions. Each of the next n lines contains one expression string in the form x/y+u/v , with no spaces. Output Format Print n lines. The i th line is the reduced sum of the i th expression, in the form A/B . Constraints 1 ≤ n ≤ 100 1

More Trilogy Innovations Sde intern Oncampus_17july OA questionsInterview experiences