Can someone help me to understand why this code fails?


  • 0
    S

    Can someone help me to understand why this code fails? why expected is 0?

    class Solution(object):
        def reverse(self, x):
            """
            :type x: int
            :rtype: int
            """
            return int(str(x)[::-1]) if x > 0 else -int(str(-x)[::-1])]
    
    Input:
    1534236469
    Output:
    9646324351
    Expected:
    0
    

Log in to reply
 

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