Expected answer wrong


  • 4
    P

    I use ruby. LeetCode gives an expected answer of integer_break(100) = 2124471432. I think this is clearly wrong because an obvious alternative 10**10 = 10,000,000,000 is greater than the expected answer.


  • 2
    C

    Good catch. I think the expected answer is clearly wrong in this case, but it might be because of integer overflow. The function needs to return an integer value and in the case of many languages like Java and C++, an 'integer' value can only range from -2,147,483,648 to 2,147,483,647. You can run into problems like this when you try to fit big numbers into small containers.


  • 0
    C

    Java has the same problem


  • 0
    Z

    2
    5
    7
    8
    18
    30
    60

    here's my test case. there might be some overflow. I was using python, pretty sure python's integer is more correct.


Log in to reply
 

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