#3201

Find the Maximum Length of Valid Subsequence I

specialist · 800 · lc medium +31 · 54.9% accepted · 639 likes · top 48%

Description

You are given an integer array nums.

A subsequence sub of length x is valid when:

(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.

Code

1
2
3