Skip to content

Practice Maximum XOR After Operations

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2317
LeetCode Problem

Maximum XOR After Operations

Problem Statement

You are given a 0-indexed integer array nums. In one operation, select any non-negative integer x and an index i, then update nums[i] to be equal to nums[i] AND (nums[i] XOR x). Note that AND is the bitwise AND operation and XOR is the bitwise XOR operation. Return the maximum possible bitwise XOR of all elements of nums after applying the operation any number of times.

Source: Maximum XOR After Operations on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [3,2,4,6]
Output
7

# Example 2

Input
nums = [1,2,3,9,2]
Output
11

Constraints

1 <= nums.length <= 10^5
0 <= nums[i] <= 10^8

Related LeetCode Problems

Practice more problems similar to Maximum XOR After Operations .

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.