Team Ai
Datasetpublic

FPEvalRepoPublic/LeetCodeMetaData

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes402downloads
maximum-frequency-after-subarray-operation.json32 linesDownload Raw Back to root
1{2  "id": 3751,3  "name": "maximum-frequency-after-subarray-operation",4  "difficulty": "Medium",5  "link": "https://leetcode.com/problems/maximum-frequency-after-subarray-operation/",6  "date": "2025-01-19",7  "task_description": "You are given an array `nums` of length `n`. You are also given an integer `k`. You perform the following operation on `nums` **once**: Select a subarray `nums[i..j]` where `0 <= i <= j <= n - 1`. Select an integer `x` and add `x` to **all** the elements in `nums[i..j]`. Find the **maximum** frequency of the value `k` after the operation. **Example 1:** **Input:** nums = [1,2,3,4,5,6], k = 1 **Output:** 2 **Explanation:** After adding -5 to `nums[2..5]`, 1 has a frequency of 2 in `[1, 2, -2, -1, 0, 1]`. **Example 2:** **Input:** nums = [10,2,3,4,5,5,4,3,2,2], k = 10 **Output:** 4 **Explanation:** After adding 8 to `nums[1..9]`, 10 has a frequency of 4 in `[10, 10, 11, 12, 13, 13, 12, 11, 10, 10]`. **Constraints:** `1 <= n == nums.length <= 105` `1 <= nums[i] <= 50` `1 <= k <= 50`",8  "test_case": [9    {10      "label": "Example 1",11      "input": "nums = [1,2,3,4,5,6], k = 1",12      "output": "2 "13    },14    {15      "label": "Example 2",16      "input": "nums = [10,2,3,4,5,5,4,3,2,2], k = 10",17      "output": "4 "18    }19  ],20  "constraints": [21    "Select a subarray nums[i..j] where 0 <= i <= j <= n - 1.",22    "Select an integer x and add x to all the elements in nums[i..j].",23    "1 <= n == nums.length <= 105",24    "1 <= nums[i] <= 50",25    "1 <= k <= 50"26  ],27  "python_template": "class Solution(object):\n    def maxFrequency(self, nums, k):\n        \"\"\"\n        :type nums: List[int]\n        :type k: int\n        :rtype: int\n        \"\"\"\n        ",28  "java_template": "class Solution {\n    public int maxFrequency(int[] nums, int k) {\n        \n    }\n}",29  "metadata": {30    "func_name": "maxFrequency"31  }32}