XOR Span Dimension Problem

XOR Span Dimension Problem — ExecCode Hard DSA Practice

Solve the XOR Span Dimension problem on ExecCode. Free online hard DSA practice in Two Pointers. Write and run code in Java, C++, Python — no signup required to run.

Problem description

The subset-XOR values of an array form a vector space over GF(2). Its dimension is the size of the XOR basis — how many independent numbers remain after Gaussian elimination. That dimension is also the number of distinct subset XORs as a power of two. Return the size of the XOR basis (rank). You are given: nums — integers Return rank of the set under XOR. Rank 0 means every subset XOR is 0.

Examples

Input {'nums': [1, 2, 3]}; Output 2. Input {'nums': [0, 0]}; Output 0. Input {'nums': [4, 4, 4]}; Output 1

Constraints

0 does not increase rank Two equal numbers contribute at most 1

Practice XOR Span Dimension free on ExecCode. Browse DSA problems, topic map, and placement guides.