Leetcode Problem 1447. Simplified Fractions

1447. Simplified Fractions

Leetcode Solutions

Using GCD to Find Simplified Fractions

  1. Initialize an empty list to store the simplified fractions.
  2. Iterate over all possible denominators from 2 to n.
  3. For each denominator, iterate over all possible numerators from 1 to one less than the denominator.
  4. For each numerator-denominator pair, calculate the GCD.
  5. If the GCD is 1, the fraction is simplified, and we add it to the list as a string in the format 'numerator/denominator'.
  6. Return the list of simplified fractions.
UML Thumbnail

Brute Force with Fraction Simplification Check

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...