3287. Find the Maximum Sequence Value of Array Hard
1/**
2 * [3287] Find the Maximum Sequence Value of Array
3 *
4 * You are given an integer array nums and a positive integer k.
5 * The value of a sequence seq of size 2 * x is defined as:
6 *
7 * (seq[0] OR seq[1] OR ... OR seq[x - 1]) XOR (seq[x] OR seq[x + 1] OR ... OR seq[2 * x - 1]).
8 *
9 * Return the maximum value of any <span data-keyword="subsequence-array">subsequence</span> of nums having size 2 * k.
10 *
11 * <strong class="example">Example 1:
12 * <div class="example-block">
13 * Input: <span class="example-io">nums = [2,6,7], k = 1</span>
14 * Output: <span class="example-io">5</span>
15 * Explanation:
16 * The subsequence [2, 7] has the maximum value of 2 XOR 7 = 5.
17 * </div>
18 * <strong class="example">Example 2:
19 * <div class="example-block">
20 * Input: <span class="example-io">nums = [4,2,5,6,7], k = 2</span>
21 * Output: <span class="example-io">2</span>
22 * Explanation:
23 * The subsequence [4, 5, 6, 7] has the maximum value of (4 OR 5) XOR (6 OR 7) = 2.
24 * </div>
25 *
26 * Constraints:
27 *
28 * 2 <= nums.length <= 400
29 * 1 <= nums[i] < 2^7
30 * 1 <= k <= nums.length / 2
31 *
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/find-the-maximum-sequence-value-of-array/
36// discuss: https://leetcode.com/problems/find-the-maximum-sequence-value-of-array/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41 pub fn max_value(nums: Vec<i32>, k: i32) -> i32 {
42 0
43 }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn test_3287() {
54 }
55}
56
Back
© 2025 bowen.ge All Rights Reserved.