1from functools importreduce2import string
3classSolution:4defintToStr(self, num):5 neg =False6ifint<0:7 num =-num
8 neg =True910 res =""11while num >0:12 n = num %1013 res.append(chr(ord("0")+ n))14 num //=1015 res = res[::-1]1617if neg:return"-"+ res
18return res
1920defstrToInt1(self, s):21iflen(s)==0:return022 neg, start =False,023if s[0]=="-":24 neg =True25 start = start +12627 res =028for i inrange(start,len(s)):29 res *=1030 res +=int(s[i])3132if neg:return"-"+ res
33return res
3435defstrToInt2(self, s):36 res =reduce(lambda runningSum, c:(runningSum *10)+ string.digits.index(c), s[s[0]in"+-":],0)37if s[0]=="-":return-res
38return res