FPEvalRepoPublic/LeetCodeMetaData
0399
1{2 "id": 3372,3 "name": "longest-strictly-increasing-or-strictly-decreasing-subarray",4 "difficulty": "Easy",5 "link": "https://leetcode.com/problems/longest-strictly-increasing-or-strictly-decreasing-subarray/",6 "date": "2024-03-31",7 "task_description": "You are given an array of integers `nums`. Return _the length of the **longest** subarray of _`nums`_ which is either **strictly increasing** or **strictly decreasing**_. **Example 1:** **Input:** nums = [1,4,3,3,2] **Output:** 2 **Explanation:** The strictly increasing subarrays of `nums` are `[1]`, `[2]`, `[3]`, `[3]`, `[4]`, and `[1,4]`. The strictly decreasing subarrays of `nums` are `[1]`, `[2]`, `[3]`, `[3]`, `[4]`, `[3,2]`, and `[4,3]`. Hence, we return `2`. **Example 2:** **Input:** nums = [3,3,3,3] **Output:** 1 **Explanation:** The strictly increasing subarrays of `nums` are `[3]`, `[3]`, `[3]`, and `[3]`. The strictly decreasing subarrays of `nums` are `[3]`, `[3]`, `[3]`, and `[3]`. Hence, we return `1`. **Example 3:** **Input:** nums = [3,2,1] **Output:** 3 **Explanation:** The strictly increasing subarrays of `nums` are `[3]`, `[2]`, and `[1]`. The strictly decreasing subarrays of `nums` are `[3]`, `[2]`, `[1]`, `[3,2]`, `[2,1]`, and `[3,2,1]`. Hence, we return `3`. **Constraints:** `1 <= nums.length <= 50` `1 <= nums[i] <= 50`",8 "test_case": [9 {10 "label": "Example 1",11 "input": "nums = [1,4,3,3,2]",12 "output": "2 "13 },14 {15 "label": "Example 2",16 "input": "nums = [3,3,3,3]",17 "output": "1 "18 },19 {20 "label": "Example 3",21 "input": "nums = [3,2,1]",22 "output": "3 "23 }24 ],25 "constraints": [26 "1 <= nums.length <= 50",27 "1 <= nums[i] <= 50"28 ],29 "python_template": "class Solution(object):\n def longestMonotonicSubarray(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n ",30 "java_template": "class Solution {\n public int longestMonotonicSubarray(int[] nums) {\n \n }\n}",31 "metadata": {32 "func_name": "longestMonotonicSubarray"33 }34}