972. Equal Rational Numbers Hard
1/**
2 * [972] Equal Rational Numbers
3 *
4 * Given two strings s and t, each of which represents a non-negative rational number, return true if and only if they represent the same number. The strings may use parentheses to denote the repeating part of the rational number.
5 * A rational number can be represented using up to three parts: <IntegerPart>, <NonRepeatingPart>, and a <RepeatingPart>. The number will be represented in one of the following three ways:
6 *
7 * <IntegerPart>
8 *
9 * For example, 12, 0, and 123.
10 *
11 *
12 * <IntegerPart><.><NonRepeatingPart>
13 *
14 * For example, 0.5, 1., 2.12, and 123.0001.
15 *
16 *
17 * <IntegerPart><.><NonRepeatingPart><(><RepeatingPart><)>
18 *
19 * For example, 0.1(6), 1.(9), 123.00(1212).
20 *
21 *
22 *
23 * The repeating portion of a decimal expansion is conventionally denoted within a pair of round brackets. For example:
24 *
25 * 1/6 = 0.16666666... = 0.1(6) = 0.1666(6) = 0.166(66).
26 *
27 *
28 * Example 1:
29 *
30 * Input: s = "0.(52)", t = "0.5(25)"
31 * Output: true
32 * Explanation: Because "0.(52)" represents 0.52525252..., and "0.5(25)" represents 0.52525252525..... , the strings represent the same number.
33 *
34 * Example 2:
35 *
36 * Input: s = "0.1666(6)", t = "0.166(66)"
37 * Output: true
38 *
39 * Example 3:
40 *
41 * Input: s = "0.9(9)", t = "1."
42 * Output: true
43 * Explanation: "0.9(9)" represents 0.999999999... repeated forever, which equals 1. [<a href="https://en.wikipedia.org/wiki/0.999..." target="_blank">See this link for an explanation.</a>]
44 * "1." represents the number 1, which is formed correctly: (IntegerPart) = "1" and (NonRepeatingPart) = "".
45 *
46 *
47 * Constraints:
48 *
49 * Each part consists only of digits.
50 * The <IntegerPart> does not have leading zeros (except for the zero itself).
51 * 1 <= <IntegerPart>.length <= 4
52 * 0 <= <NonRepeatingPart>.length <= 4
53 * 1 <= <RepeatingPart>.length <= 4
54 *
55 */
56pub struct Solution {}
57
58// problem: https://leetcode.com/problems/equal-rational-numbers/
59// discuss: https://leetcode.com/problems/equal-rational-numbers/discuss/?currentPage=1&orderBy=most_votes&query=
60
61// submission codes start here
62
63impl Solution {
64 pub fn is_rational_equal(s: String, t: String) -> bool {
65 false
66 }
67}
68
69// submission codes end
70
71#[cfg(test)]
72mod tests {
73 use super::*;
74
75 #[test]
76 fn test_972() {
77 }
78}
79
Back
© 2025 bowen.ge All Rights Reserved.