Search⌘ K
AI Features

Solution: Equal Rational Numbers

Understand how to convert rational numbers with repeating decimals into exact fractions. This lesson teaches you to compare two strings representing rational numbers by transforming them into reduced fractions to check for equality. You will learn the algebraic method and how to handle different decimal formats.

Statement

Given two strings s and t, each representing 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.

A rational number can be represented using up to three parts: <IntegerPart>, <NonRepeatingPart>, and <RepeatingPart>. The number will be expressed in one of the following three formats:

  • <IntegerPart>

    • For example, 1212 ...