FPEvalRepoPublic/LeetCodeMetaData
0399
1{2 "id": 3716,3 "name": "longest-subsequence-with-decreasing-adjacent-difference",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/longest-subsequence-with-decreasing-adjacent-difference/",6 "date": "2024-12-21",7 "task_description": "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. **Example 1:** **Input:** nums = [16,6,3] **Output:** 3 **Explanation:** The longest subsequence is `[16, 6, 3]` with the absolute adjacent differences `[10, 3]`. **Example 2:** **Input:** nums = [6,5,3,4,2,1] **Output:** 4 **Explanation:** The longest subsequence is `[6, 4, 2, 1]` with the absolute adjacent differences `[2, 2, 1]`. **Example 3:** **Input:** nums = [10,20,10,19,10,20] **Output:** 5 **Explanation:** The longest subsequence is `[10, 20, 10, 19, 10]` with the absolute adjacent differences `[10, 10, 9, 9]`. **Constraints:** `2 <= nums.length <= 104` `1 <= nums[i] <= 300`",8 "test_case": [9 {10 "label": "Example 1",11 "input": "nums = [16,6,3]",12 "output": "3 "13 },14 {15 "label": "Example 2",16 "input": "nums = [6,5,3,4,2,1]",17 "output": "4 "18 },19 {20 "label": "Example 3",21 "input": "nums = [10,20,10,19,10,20]",22 "output": "5 "23 }24 ],25 "constraints": [26 "2 <= nums.length <= 104",27 "1 <= nums[i] <= 300"28 ],29 "python_template": "class Solution(object):\n def longestSubsequence(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n ",30 "java_template": "class Solution {\n public int longestSubsequence(int[] nums) {\n \n }\n}",31 "metadata": {32 "func_name": "longestSubsequence"33 }34}