Programmazione competitivaFacile

Coppia XOR minima

Guida dettagliata e implementazione Python per il problema della "coppia XOR minima".

Dichiarazione del problema

Facile

Scrivi una funzione min_xor_pair(arr) che accetta un array di interi non negativi arr e restituisce la somma XOR minima di due elementi qualsiasi nell'array.

Vincoli
  • 2 <= len(arr) <= 10^5
  • 0 <= arr[i] <= 10^9

Esempi

Example 1
Input
min_xor_pair([9, 5, 3])
Output
6
Explanation

9^5 = 12, 9^3 = 10, 5^3 = 6. The minimum is 6.

Example 2
Input
min_xor_pair([1, 2, 3, 4])
Output
1
Explanation

2^3 = 1, which is the minimum XOR sum.

Need a Hint?
Prendi in considerazione l'utilizzo di strutture dati specifiche per Trie 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.