FPEvalRepoPublic/LeetCodeMetaData
0399
1{2 "id": 2730,3 "name": "maximum-or",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/maximum-or/",6 "date": "2023-04-29",7 "task_description": "You are given a **0-indexed** integer array `nums` of length `n` and an integer `k`. In an operation, you can choose an element and multiply it by `2`. Return _the maximum possible value of _`nums[0] | nums[1] | ... | nums[n - 1]` _that can be obtained after applying the operation on nums at most _`k`_ times_. Note that `a | b` denotes the **bitwise or** between two integers `a` and `b`. **Example 1:** ``` **Input:** nums = [12,9], k = 1 **Output:** 30 **Explanation:** If we apply the operation to index 1, our new array nums will be equal to [12,18]. Thus, we return the bitwise or of 12 and 18, which is 30. ``` **Example 2:** ``` **Input:** nums = [8,1,2], k = 2 **Output:** 35 **Explanation:** If we apply the operation twice on index 0, we yield a new array of [32,1,2]. Thus, we return 32|1|2 = 35. ``` **Constraints:** `1 <= nums.length <= 105` `1 <= nums[i] <= 109` `1 <= k <= 15`",8 "test_case": [9 {10 "label": "Example 1",11 "input": "nums = [12,9], k = 1",12 "output": "30 "13 },14 {15 "label": "Example 2",16 "input": "nums = [8,1,2], k = 2",17 "output": "35 "18 }19 ],20 "constraints": [21 "1 <= nums.length <= 105",22 "1 <= nums[i] <= 109",23 "1 <= k <= 15"24 ],25 "python_template": "class Solution(object):\n def maximumOr(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 long maximumOr(int[] nums, int k) {\n \n }\n}",27 "metadata": {28 "func_name": "maximumOr"29 }30}