题目描述
Given two fractions a/b and c/d, compare them and print the larger of the two.
Example 1:
Input:
s = "5/6, 11/45"
Output: 5/6
Explanation:
5/6=0.8333... and 11/45=0.2444....
Clearly, 5/6 is greater, so we output it.
Example 2:
Input:
s = "8/1, 8/1"
Output: equal
Explanation:
We can see that both the fractions are same,
so they are equal.
Your Task:
You don't need to read input or print anything. Your task is to complete the function compareFrac() which takes the string s as input parameters and returns the fraction that is greater. If they are equal, then return "equal".
Expected Time Complexity: O(len|s|)
Expected Auxiliary Space: O(1)
Constraints:
0<=a,c<=1000
1<=b,d<=1000
输入格式
见题面
输出格式
见题面
样例输入
s = "5/6, 11/45"
样例输出
5/6