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 1:
Input: numerator = 1, denominator = 2
Output: "0.5"
Example 2:
Input: numerator = 2, denominator = 1
Output: "2"
Example 3:
Input: numerator = 2, denominator = 3
Output: "0.(6)"
class Solution:
     def fractionToDecimal(self, numerator, denominator):
         """
         :type numerator: int
         :type denominator: int
         :rtype: str
         """
         sign=0
         if numerator*denominator<0:
             sign =-1
         numerator,denominator = abs(numerator),abs(denominator)
         n = numerator
         s =''
         if n >denominator:
             s +=str(n//denominator)
             n %=denominator
         else:
             s ='0'
         if sign==-1:
             s = '-'+s
         if n == 0:
             return s
         s +='.'
         t =[n]
         x = n
         s1=''
         while 1:
             x *=10
             s1 +=str(x//denominator)
             x %=denominator
             if x in t or  x==0:
                 break
             else:
                 t.append(x)
         if x in t:
             s1=s1[:t.index(x)]+'('+s1[t.index(x):]+')'
 
             
         return s+s1

class Solution:
     def fractionToDecimal(self, numerator, denominator):
         """
         :type numerator: int
         :type denominator: int
         :rtype: str
         """
         sign=0
         if numerator*denominator<0:
             sign =-1
         numerator,denominator = abs(numerator),abs(denominator)
         n = numerator
         s =''
         if n >denominator:
             s +=str(n//denominator)
             n %=denominator
         else:
             s ='0'
         if sign==-1:
             s = '-'+s
         if n == 0:
             return s
         s +='.'
         t =[n]
         x = n
         s1=''
         while 1:
             x *=10
             s1 +=str(x//denominator)
             x %=denominator
             if x in t or  x==0:
                 break
             else:
                 t.append(x)
         if x in t:
             s1=s1[:t.index(x)]+'('+s1[t.index(x):]+')'
 
             
         return s+s1
