Skip to main content
PreparationZone Logo
PreparationZone
Back to Coding

Coding · Medium · Pro

Divide two integers without using multiplication or division

CodingBit ManipulationSenior
Model answerPreview

Approach

  • Use bit shifts to subtract largest power-of-two multiples of divisor.
  • Handle overflow when divisor is Integer.MIN_VALUE.

Java Solution

Java
int div…