CoolFace
Datasetpublic

FPEvalDataset/LeetCodeProblem

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes305downloads
1{2    "id": 3193,3    "name": "maximum_strong_pair_xor_i",4    "difficulty": "Easy",5    "link": "https://leetcode.com/problems/maximum-strong-pair-xor-i/",6    "date": "2023-11-05 00:00:00",7    "task_description": "You are given a **0-indexed** integer array `nums`. A pair of integers `x` and `y` is called a **strong** pair if it satisfies the condition: `|x - y| <= min(x, y)` You need to select two integers from `nums` such that they form a strong pair and their bitwise `XOR` is the **maximum** among all strong pairs in the array. Return _the **maximum** _`XOR`_ value out of all possible strong pairs in the array_ `nums`. **Note** that you can pick the same integer twice to form a pair. **Example 1:** ``` **Input:** nums = [1,2,3,4,5] **Output:** 7 **Explanation:** There are 11 strong pairs in the array `nums`: (1, 1), (1, 2), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (3, 5), (4, 4), (4, 5) and (5, 5). The maximum XOR possible from these pairs is 3 XOR 4 = 7. ``` **Example 2:** ``` **Input:** nums = [10,100] **Output:** 0 **Explanation:** There are 2 strong pairs in the array `nums`: (10, 10) and (100, 100). The maximum XOR possible from these pairs is 10 XOR 10 = 0 since the pair (100, 100) also gives 100 XOR 100 = 0. ``` **Example 3:** ``` **Input:** nums = [5,6,25,30] **Output:** 7 **Explanation:** There are 6 strong pairs in the array `nums`: (5, 5), (5, 6), (6, 6), (25, 25), (25, 30) and (30, 30). The maximum XOR possible from these pairs is 25 XOR 30 = 7 since the only other non-zero XOR value is 5 XOR 6 = 3. ``` **Constraints:** `1 <= nums.length <= 50` `1 <= nums[i] <= 100`",8    "public_test_cases": [9        {10            "label": "Example 1",11            "input": "nums = [1,2,3,4,5]",12            "output": "7 "13        },14        {15            "label": "Example 2",16            "input": "nums = [10,100]",17            "output": "0 "18        },19        {20            "label": "Example 3",21            "input": "nums = [5,6,25,30]",22            "output": "7 "23        }24    ],25    "private_test_cases": [26        {27            "input": [28                1,29                4,30                12,31                14,32                19,33                26,34                38,35                44,36                47,37                48,38                49,39                54,40                59,41                59,42                65,43                68,44                71,45                72,46                81,47                82,48                88,49                89,50                89,51                89,52                9653            ],54            "output": 12755        },56        {57            "input": [58                23,59                7860            ],61            "output": 062        },63        {64            "input": [65                58,66                66,67                9568            ],69            "output": 12070        },71        {72            "input": [73                1,74                3,75                5,76                7,77                14,78                15,79                15,80                16,81                26,82                33,83                36,84                40,85                40,86                42,87                44,88                48,89                58,90                59,91                62,92                64,93                68,94                69,95                83,96                85,97                90,98                92,99                98,100                98101            ],102            "output": 127103        },104        {105            "input": [106                3,107                4,108                5,109                5,110                18,111                21,112                52,113                73,114                80,115                82,116                93117            ],118            "output": 125119        }120    ],121    "haskell_template": "maximumStrongPairXor :: [Int] -> Int\nmaximumStrongPairXor nums ",122    "ocaml_template": "let maximumStrongPairXor (nums: int list) : int =  ",123    "scala_template": "def maximumStrongPairXor(nums: List[Int]): Int = { \n    \n}",124    "java_template": "class Solution {\n    public int maximumStrongPairXor(int[] nums) {\n        \n    }\n}",125    "python_template": "class Solution(object):\n    def maximumStrongPairXor(self, nums):\n        \"\"\"\n        :type nums: List[int]\n        :rtype: int\n        \"\"\"\n        "126}