3 lines simple c++ solution(18ms)


  • 0
    G
    class Solution {
    public:
        int divide(int dividend, int divisor) {
            if(divisor == 0||(dividend == INT_MIN && divisor == -1))
                return INT_MAX;
            else
                return (dividend-dividend%divisor)/divisor;
        }
    };
    

Log in to reply
 

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