Fraction

Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.

If the fractional part is repeating, enclose the repeating part in parentheses.

Example :

Given numerator = 1, denominator = 2, return "0.5"
Given numerator = 2, denominator = 1, return "2"
Given numerator = 2, denominator = 3, return "0.(6)"
Interview Code Editor
Hints
  • Solution Approach
  • Complete Solution
2525 successful submissions.
Asked In:
  • Amazon
  • Microsoft
Click here to jump start your coding interview preparation