LeetCode – Divide Two Integers (Java)
Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. Analysis This problem can be solved based on the fact that any number can be converted to the format of the following: num=a_0*2^0+a_1*2^1+a_2*2^2+…+a_n*2^n The time complexity is O(logn). Java Solution public int divide(int dividend, int divisor) { //handle special … Read more