Find the maximum length of a subsequence that satisfies the problem's validity rule.
Given an integer array, choose a subsequence (not necessarily contiguous) whose elements satisfy the validity condition defined by the problem. Your task is to compute the maximum possible length of such a valid subsequence.
A subsequence keeps the original order of the chosen elements, but elements may be skipped. Among all valid subsequences, return the largest length that can be achieved.
Input Format
- An integer array
nums. - The exact validity rule is determined by the original problem statement.
Output Format
Return a single integer: the maximum length of a valid subsequence that can be formed from the array.
Constraints
- The array may contain repeated values.
- Preserve the original order of chosen elements.
- The answer must be the maximum possible length among all valid subsequences.
Example 1
Input
nums = [1, 2, 3]
Output
3
Explanation
A valid subsequence can use all three elements if they satisfy the required condition.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.