2025-08-22 10:58:21 +0000 UTC

Maximum Strong Pair XOR I

Code

class Solution:
    def maximumStrongPairXor(self, nums: List[int]) -> int:
        max_xor = 0
        for num1, num2 in itertools.permutations(nums, 2):
            if abs(num2 - num1) <= min(num1, num2):
                max_xor = max(max_xor, num1 ^ num2)
        return max_xor