Le migliori 150 intervisteFacile

Bit inversi

Guida dettagliata e implementazione Python per il problema dei "bit inversi".

Dichiarazione del problema

Facile

Bit inversi di un dato intero senza segno a 32 bit.

Scrivi una funzione reverseBits(n: int) -> int.

Vincoli
  • n must be a 32-bit unsigned integer

Esempi

Example 1
Input
n = 43261596
Output
964176192
Explanation

The input binary string 00000010100101000001111010011100 reversed is 00111001011110000010100101000000, representing 964176192.

Need a Hint?
Prendi in considerazione l'utilizzo di strutture dati specifiche per la manipolazione dei bit come set o heap.
Edge Cases to Watch
  • Strutture di input vuote
  • Ingressi a elemento singolo
  • Grandi limiti numerici

Pronto a risolvere?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

Apri nell'editor
Found this breakdown helpful?

PyRun is built and maintained by an independent solo developer. If this helped your interview prep, consider buying a coffee!

Buy me a coffee

Risorse Python consigliate

Espandi le tue conoscenze con tutorial interattivi, foglietti illustrativi e confronti di codici correlati.