Baseline Bit Manipulation · Learn Bit Manipulation O(log n) over the absolute dividend · O(1)
A stockroom robot must split a shelf of length `dividend` into bays of length `divisor` — but its controller has no multiply, divide, or modulo circuit. It can only double and shift. The robot repeatedly finds the largest doubled divisor that still fits, peels that block off, and records how many such blocks each doubling step contributed, until the shelf is fully subdivided.
Input: Two integers dividend and divisor (divisor is never zero).
Output: The quotient, truncated toward zero.
-10^9 <= dividend, divisor <= 10^9divisor != 0Input: {"dividend":10,"divisor":3}
Output: 3
Three full bays of 3 fit with a remainder of 1.
Input: {"dividend":43,"divisor":-8}
Output: -5
Opposite signs flip the quotient; 43 / 8 truncates to 5, so the answer is -5.