leetcode 29 Divide Two Integers
Posted 王坤1993
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode 29 Divide Two Integers相关的知识,希望对你有一定的参考价值。
class Solution { public: int divide(int dividend, int divisor) { long long res = 0; long long m = abs((long long)dividend), n = abs((long long)divisor); if (m < n) return 0; long long t = n, p = 1; while (m > (t << 1)) { t <<= 1; p <<= 1; } res += p + divide(m - t, n); if ((dividend < 0) ^ (divisor < 0)) res = -res; return res > INT_MAX ? INT_MAX : res; } };
以上是关于leetcode 29 Divide Two Integers的主要内容,如果未能解决你的问题,请参考以下文章
LeetCode 29. Divide Two Integers
Leetcode 29. Divide Two Integers
[LeetCode] 29. Divide Two Integers
LeetCode-29-Divide Two Integers