@@ -0,0 +1,978 @@
+package dtprogrammer.github.io.p29;%0A%0A/**%0A * 29. Divide Two Integers%0A * %3Cp%3E%0A * Divide two integers without using multiplication, division and mod operator.%0A * %3Cp%3E%0A * If it is overflow, return MAX_INT.%0A * %3Cp%3E%0A * Time complexity:%0A */%0Apublic class Solution %7B%0A%0A    public int divide(int divided, int divisor) %7B%0A%0A        if (divisor == 0 %7C%7C (divided == Integer.MIN_VALUE && divisor == -1)) %7B%0A            return Integer.MAX_VALUE;%0A        %7D%0A%0A        int sign = (divided %3C 0) %5E (divisor %3C 0) ? -1 : 1;%0A%0A%0A        int result = 0;%0A        long dividendMod = Math.abs((long) divided);%0A        long dvs = Math.abs((long) divisor);%0A        while (dividendMod %3E= dvs) %7B%0A            long loop = 1;%0A            long divisorMod = dvs;%0A            while (dividendMod %3E= (divisorMod %3C%3C 1)) %7B%0A                divisorMod %3C%3C= 1;%0A                loop %3C%3C= 1;%0A            %7D%0A            dividendMod -= divisorMod;%0A            result += loop;%0A        %7D%0A        return sign == 1 ? result : -result;%0A    %7D%0A%7D%0A

29. Divide Two Integers