Read Time:53 Second
Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0.
Example 1:Input: x = 123 Output: 321
Example 2:Input: x = -123 Output: -321
Example 3:Input: x = 120 Output: 21
Solution 1
class Solution:
def reverse(self, x: int) -> int:
it_max= 2**31 - 1
it_min= -2**31
rev=0
sign=1
if x<0:
sign=-1
else:
sign=1
x=abs(x)
rev= int(str(x)[::-1])*sign
if rev >it_max:
return 0
if rev <it_min:
return 0
return rev
Solution 2
class Solution:
def reverse(self, x: int) -> int:
it_max= 2**31 - 1
it_min= -2**31
rev=0
sign=1
if x<0:
sign=-1
else:
sign=1
x=abs(x)
while x>0:
z= x%10
rev= rev*10+z
x=x//10
if rev >it_max:
return 0
if rev <it_min:
return 0
return rev*sign

Elitepipe Plastic Factory’s commitment to customer satisfaction is evident in their prompt delivery schedules and exceptional after-sales service. Elitepipe Plastic Factory
Hmm is anyone else encountering problems with the images on this blog loading? I’m trying to figure out if its a problem on my end or if it’s the blog. Any responses would be greatly appreciated.
Hi my family member! I want to say that this post is awesome, nice written and come with approximately all significant infos. I would like to peer extra posts like this.
Fantastic site A lot of helpful info here Im sending it to some buddies ans additionally sharing in delicious And naturally thanks on your sweat
viagra online usa pharmacy
Somebody essentially lend a hand to make significantly posts I might state That is the very first time I frequented your web page and up to now I surprised with the research you made to create this particular put up amazing Excellent job
I have been surfing online more than 3 hours today yet I never found any interesting article like yours It is pretty worth enough for me In my opinion if all web owners and bloggers made good content as you did the web will be much more useful than ever before
Thanks I have recently been looking for info about this subject for a while and yours is the greatest I have discovered so far However what in regards to the bottom line Are you certain in regards to the supply
hiI like your writing so much share we be in contact more approximately your article on AOL I need a specialist in this area to resolve my problem Maybe that is you Looking ahead to see you
I was suggested this web site by my cousin Im not sure whether this post is written by him as no one else know such detailed about my trouble You are incredible Thanks