#3202

Find the Maximum Length of Valid Subsequence II

specialist · 765 · lc medium +31 · 57.2% accepted · 650 likes · top 52%

Description

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

A subsequence sub of length x is valid when:

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

Code

1
2
3