Programação CompetitivaDifícil

Par XOR Máximo

Guia detalhado e implementação de Python para o problema 'Par máximo de XOR'.

Declaração do problema

Difícil

Escreva uma função max_xor_pair(arr) que pegue um array de inteiros não negativos arr e retorne a soma XOR máxima de quaisquer dois elementos no array.

Restrições
  • 2 <= len(arr) <= 10^5
  • 0 <= arr[i] <= 10^9

Exemplos

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?
Considere usar estruturas de dados específicas do Trie, como conjuntos ou heaps.
Edge Cases to Watch
  • Estruturas de entrada vazias
  • Entradas de elemento único
  • Grandes limites numéricos

Pronto para resolver?

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

Abrir no 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

Recursos Python recomendados

Expanda seu conhecimento com tutoriais interativos relacionados, folhas de dicas e comparações de código.