Practice Longest Subsequence With Decreasing Adjacent Difference
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Longest Subsequence With Decreasing Adjacent Difference
Problem Statement
You are given an array of integers nums. Your task is to find the length of the longest subsequence seq of nums, such that the absolute differences between consecutive elements form a non-increasing sequence of integers. In other words, for a subsequence seq0, seq1, seq2, ..., seqm of nums, |seq1 - seq0| >= |seq2 - seq1| >= ... >= |seqm - seqm - 1|. Return the length of such a subsequence.
Source: Longest Subsequence With Decreasing Adjacent Difference on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [16,6,3]
3
# Example 2
nums = [6,5,3,4,2,1]
4
# Example 3
nums = [10,20,10,19,10,20]
5
Constraints
Related LeetCode Problems
Practice more problems similar to Longest Subsequence With Decreasing Adjacent Difference.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.