Class Solution
java.lang.Object
g0901_1000.s0972_equal_rational_numbers.Solution
972 - Equal Rational Numbers.<p>Hard</p>
<p>Given two strings <code>s</code> and <code>t</code>, each of which represents a non-negative rational number, return <code>true</code> if and only if they represent the same number. The strings may use parentheses to denote the repeating part of the rational number.</p>
<p>A <strong>rational number</strong> can be represented using up to three parts: <code><IntegerPart></code>, <code><NonRepeatingPart></code>, and a <code><RepeatingPart></code>. The number will be represented in one of the following three ways:</p>
<ul>
<li><code><IntegerPart></code>
<ul>
<li>For example, <code>12</code>, <code>0</code>, and <code>123</code>.</li>
</ul>
</li>
<li><code><IntegerPart>**<.>**<NonRepeatingPart></code>
<ul>
<li>For example, <code>0.5</code>, <code>1.</code>, <code>2.12</code>, and <code>123.0001</code>.</li>
</ul>
</li>
<li><code><IntegerPart>**<.>**<NonRepeatingPart>**<(>**<RepeatingPart>**<)>**</code>
<ul>
<li>For example, <code>0.1(6)</code>, <code>1.(9)</code>, <code>123.00(1212)</code>.</li>
</ul>
</li>
</ul>
<p>The repeating portion of a decimal expansion is conventionally denoted within a pair of round brackets. For example:</p>
<ul>
<li><code>1/6 = 0.16666666... = 0.1(6) = 0.1666(6) = 0.166(66)</code>.</li>
</ul>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> s = “0.(52)”, t = “0.5(25)”</p>
<p><strong>Output:</strong> true</p>
<p><strong>Explanation:</strong> Because “0.(52)” represents 0.52525252…, and “0.5(25)” represents 0.52525252525….. , the strings represent the same number.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> s = “0.1666(6)”, t = “0.166(66)”</p>
<p><strong>Output:</strong> true</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> s = “0.9(9)”, t = “1.”</p>
<p><strong>Output:</strong> true</p>
<p><strong>Explanation:</strong> “0.9(9)” represents 0.999999999… repeated forever, which equals</p>
<ol>
<li>[<a href="https://en.wikipedia.org/wiki/0.999..." target="_top">See this link for an explanation.</a>] “1.” represents the number 1, which is formed correctly: (IntegerPart) = “1” and (NonRepeatingPart) = "".</li>
</ol>
<p><strong>Constraints:</strong></p>
<ul>
<li>Each part consists only of digits.</li>
<li>The <code><IntegerPart></code> does not have leading zeros (except for the zero itself).</li>
<li><code>1 <= <IntegerPart>.length <= 4</code></li>
<li><code>0 <= <NonRepeatingPart>.length <= 4</code></li>
<li><code>1 <= <RepeatingPart>.length <= 4</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
isRationalEqual
-