Input 1534236469 but expected 0 ?


  • 0
    E

    Input:
    1534236469
    Output:
    9646324351
    Expected:
    0

    class Solution(object):
        def reverse(self, x):
            """
            :type x: int
            :rtype: int
            """
            if x < 0:
                n = -1
            else:
                n = 1
            if x == 0:
                return 0
            else:
                x = str(abs(x))
                test = ''
                for y in x[::-1]:
                    test+=y
                    
            return n*int(test)
    

    Says expected 0 for the output? any answers?


  • 0
    C
    This post is deleted!

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.