Tap here to switch tabs
Problem
Submissions

Problem: Find the Maximum Length of Valid Subsequence I

Try to solve the Find the Maximum Length of Valid Subsequence I problem.

Statement

You are given an integer array nums.

A subsequence sub of nums having length xx is called valid if:

(sub[0] + sub[1]) % 2 == (sub[1] + sub[2]) % 2 == ... == (sub[x - 2] + sub[x - 1]) % 2

Return the length of the longest valid subsequence of nums.

A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.

Constraints:

  • 2<=2 <= nums.length <=2∗105<= 2 * 10^5

  • 1<=1 <= nums[i] <=107<= 10^7

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Maximum Length of Valid Subsequence I

Try to solve the Find the Maximum Length of Valid Subsequence I problem.

Statement

You are given an integer array nums.

A subsequence sub of nums having length xx is called valid if:

(sub[0] + sub[1]) % 2 == (sub[1] + sub[2]) % 2 == ... == (sub[x - 2] + sub[x - 1]) % 2

Return the length of the longest valid subsequence of nums.

A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.

Constraints:

  • 2<=2 <= nums.length <=2∗105<= 2 * 10^5

  • 1<=1 <= nums[i] <=107<= 10^7