Something is wrong in test cases? [python]


  • 0
    A
    class Solution(object):
    def reverse(self, x):
        """
        :type x: int
        :rtype: int
        """
        
        if x<0:
            flag=False
            x=-x
        else:
            flag=True
            
        r=0
        while x>0:
            tail=x%10
            r=r*10+tail
            x=x/10
        if not flag:
            r=-r
            
        return r
    

    when I submit my answer, the result is:
    Input:
    1534236469

    Output:
    9646324351

    Expected:
    0

    -- why 0 is expected??? confused...


  • 0
    F

    Integer overflows is in consideration.

    However, integers in python never overflow.


  • 0
    A

    you mean that the test case is wrong?


  • 0
    F

    i have the same problem in javascript..
    so it really is the test case problem??


Log in to reply
 

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