Find Max Length of Subsequence
Updated
Problem 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 Phone Screen questions
- Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
- Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
- Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
- Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Logger Rate Limiter with Every-Arrival HistoryPHONE SCREEN · Seen Nov 2026
- Minimum Total Layover WaitPHONE SCREEN · Seen Nov 2026
- Reach a Destination Through Scheduled FlightsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Word BreakAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Count Ordered Combination Sums with Negative ValuesPinterest · PHONE SCREENPinterest interview questions
- Predicate Expression Tree EvaluatorMongoDB · PHONE SCREENMongoDB interview questions
- Word Break IIBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Longest Fibonacci-Like SubsequenceAdobe · PHONE SCREENAdobe interview questions
- Longest Common Contiguous Browser HistoryRoblox · PHONE SCREENRoblox interview questions
- Longest Common URL History RunDatadog · PHONE SCREENDatadog interview questions
- Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
- Optimize Discount Selection Under a Point BudgetPalantir · OAPalantir interview questions
- Maximum Points by Deleting ElementsIBM · OAIBM interview questions
Google interview experiences
- Google L4 SWE Phone Screen: 1 Experience
- Google ML Engineering Manager Onsite: 1 Experience
- Google Experienced SWE First Round and Onsite: 1 Experience
- Google AI Coding Interview and AI OA: 2 Experiences
- Google SWE Intern Interview Results Timeline: 13 Experiences
- Google L4 SWE Phone Screen and Kirkland Onsite: 1 Experience