3202. Find the Maximum Length of Valid Subsequence II
You are given an integer array
nums
and a positive integerk
.A subsequence
sub
ofnums
with lengthx
is called valid if it satisfies:
(sub[0] + sub[1]) % k == (sub[1] + sub[2]) % k == ... == (sub[x - 2] + sub[x - 1]) % k.
Return the length of the longest valid subsequence of
nums
.
c++
1 |
|