FPEvalRepoPublic/LeetCodeMetaData
0399
1{2 "id": 2832,3 "name": "find-the-longest-equal-subarray",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/find-the-longest-equal-subarray/",6 "date": "2023-08-13",7 "task_description": "You are given a **0-indexed** integer array `nums` and an integer `k`. A subarray is called **equal** if all of its elements are equal. Note that the empty subarray is an **equal** subarray. Return _the length of the **longest** possible equal subarray after deleting **at most** _`k`_ elements from _`nums`. A subarray is a contiguous, possibly empty sequence of elements within an array. **Example 1:** ``` **Input:** nums = [1,3,2,3,1,3], k = 3 **Output:** 3 **Explanation:** It's optimal to delete the elements at index 2 and index 4. After deleting them, nums becomes equal to [1, 3, 3, 3]. The longest equal subarray starts at i = 1 and ends at j = 3 with length equal to 3. It can be proven that no longer equal subarrays can be created. ``` **Example 2:** ``` **Input:** nums = [1,1,2,2,1,1], k = 2 **Output:** 4 **Explanation:** It's optimal to delete the elements at index 2 and index 3. After deleting them, nums becomes equal to [1, 1, 1, 1]. The array itself is an equal subarray, so the answer is 4. It can be proven that no longer equal subarrays can be created. ``` **Constraints:** `1 <= nums.length <= 105` `1 <= nums[i] <= nums.length` `0 <= k <= nums.length`",8 "test_case": [9 {10 "label": "Example 1",11 "input": "nums = [1,3,2,3,1,3], k = 3",12 "output": "3 "13 },14 {15 "label": "Example 2",16 "input": "nums = [1,1,2,2,1,1], k = 2",17 "output": "4 "18 }19 ],20 "constraints": [21 "1 <= nums.length <= 105",22 "1 <= nums[i] <= nums.length",23 "0 <= k <= nums.length"24 ],25 "python_template": "class Solution(object):\n def longestEqualSubarray(self, nums, k):\n \"\"\"\n :type nums: List[int]\n :type k: int\n :rtype: int\n \"\"\"\n ",26 "java_template": "class Solution {\n public int longestEqualSubarray(List<Integer> nums, int k) {\n \n }\n}",27 "metadata": {28 "func_name": "longestEqualSubarray"29 }30}