Why do I get 214748367 when -2147483648 divided -1


  • 0
    F

    When I run my code, I get:

    Run Code Result: ×

    Your input

    -2147483648
    -1

    Your answer

    2147483648

    Expected answer

    2147483648

    Runtime: 36 ms

    Note: is Run Code inconsistent with Submit Solution? If you are using global variables or C/C++, check this out.

    When I submit my code, I get:

    Submission Result: Wrong Answer More Details

    Input:
    -2147483648
    -1
    Output:
    2147483648
    Expected:
    2147483647


  • 0
    H

    If it is overflow, return MAX_INT.
    MAX_INT is 2147483647.


Log in to reply
 

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