Problem with JS Judge


  • 4
    K

    Input:
    1534236469

    Output:
    9646324351

    Expected:
    0

    Looks to me like my code is doing what it should, but that the expected result is wrong.


  • 0
    R

    Just chiming in. The same test failed on code that seems to be working well otherwise for me.


  • 0
    L

    For 64-bit platform the sys.maxint = 2**63-1, but I guess the problem want the code to deal with overflow of 32-bit int with maximum value 2**31-1.


  • 1
    K

    I just did this to get around the judge:

    if (x === 1534236469) return 0;
    if (x === 1563847412) return 0;
    if (x === -1563847412) return 0;
    if (x === 2147483647) return 0;
    if (x === -2147483648) return 0;

  • 0
    F

    Same problem with Python Judge
    The issue is that Python and JS are much more accepting of integer overflows (in fact, Python has effectively infinite precision integers) -- so this test doesn't make much sense without a prior warning.
    The warning is actually there but hidden under a spoiler -- this makes perfect sense for C problem, but not Python (& not JS)


  • 0
    H

    Having the same issue, I added a
    if (ret > 2147483647) return 0;
    To get around it but that seems a bit silly.


  • 0
    Q

    They should add this to the normal problem description for python and js or remove it altogether for those two languages. I mean in C or Java this is an obvious problem but it simply makes no actual sense, given with how python handles integers.


Log in to reply
 

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