Programmazione competitivaDifficile

Coppia XOR massima

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

Dichiarazione del problema

Difficile

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

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

Esempi

Example 1
Input
max_xor_pair([3, 10, 5, 25, 2, 8])
Output
28
Explanation

The maximum XOR is obtained by pairing 5 and 25 (5^25 = 28).

Example 2
Input
max_xor_pair([8, 10, 2])
Output
10
Explanation

The maximum XOR is obtained by pairing 8 and 2 (8^2 = 10).

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.