Re: Why this answer is wrong?
Did I meet a bug of leetcode system?please help me!
def reverse(self, x):
:type x: int
f = 0
if x<0: x=-x f = 1 if f==0 and x>1000000003: return 0 if f==1 and x>1000000003: return -x l = len(str(x)) x = str(x) y ='' for i in xrange(l): y = x[i] + y y = int(y) if f==1: y = -y return y
But the system said:
It's amazing !!Why???
if f==1: y = -y return y
Why the expected number is a little different from the input number?
I think it should be 0 or as same as the input number
But...it just changed 3 numbers!
the system wrong?
@zaixiahanli Your code outputs the input because you pretty much explicitly tell it to. With your
if f==1 and x>1000000003: return -x. Did you forget and overlook that part?
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.