Problem · Array
Find Max Length of Subsequence
Learn this problemProblem statement
Given a list of integers, the task is to find the maximum length of subsequence having increasing consecutive elements that increase by a value of 1.
Function
findMaxLengthOfSubsequence(nums: int[]) → int
Complete the function findMaxLengthOfSubsequence in the editor.
findMaxLengthOfSubsequence has the following parameter:
int[] nums: an array of integers
Returns
int: the maximum length of the subsequence
Examples
Example 1
nums = [1, 0, 2, 3, 2, 4, 9, 6, 5]return = 5
The longest subsequence with consecutive elements increasing by 1 is 1, 2, 3, 4, 5, which has a length of 5.
Constraints
1 <= nums.length <= 10^5-10^9 <= nums[i] <= 10^9
More Google problems
- Deduplicate Logs: Keep FirstONSITE INTERVIEW · Seen Jul 2026
- Deduplicate Logs: Keep LatestONSITE INTERVIEW · Seen Jul 2026
- Find a Template Across Binary-Tree LeavesONSITE INTERVIEW · Seen Jul 2026
- Maximum Programmer-Problem MatchingONSITE INTERVIEW · Seen Jul 2026
- Minimum Direction ViolationsONSITE INTERVIEW · Seen Jul 2026
- Stream Latest Log VersionsONSITE INTERVIEW · Seen Jul 2026
- Stream Unique Logs in Timestamp OrderONSITE INTERVIEW · Seen Jul 2026
- Top-K IP Addresses from File RecordsONSITE INTERVIEW · Seen Jul 2026