2025-08-22 13:58:21 +0300 MSK

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