#3287

Find the Maximum Sequence Value of Array

hard · 21.2% accepted · 88 likes · top 2%

array · dynamic programming · bit manipulation

⊣ practice⊣ open on leetcode ↗

Description

You are given an integer array nums and a positive integer k.

The value of a sequence seq of size 2 * x is defined as:

- (seq[0] OR seq[1] OR ... OR seq[x - 1]) XOR (seq[x] OR seq[x + 1] OR ... OR seq[2 * x - 1]).

Return the maximum value of any subsequence of nums having size 2 * k.

Solution