Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Longest Subsequence With Non-Zero Bitwise XOR

XPChallenge Points: 20
levelLevel: Medium

You are given an array of integers nums
Your task is to find the length of the longest subsequence such that the bitwise XOR of all elements in that subsequence is non-zero.
If no such subsequence exists, return 0.
A subsequence is any sequence obtained by deleting some (possibly zero) elements from the array without changing the order of the remaining elements.

Example 1:

Input: nums = [3, 5, 6]

Output: 2

Example 2:

Input: nums = [4, 7, 9]

Output: 3

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result