TheRealSamuel/LeetCodeProblem
0564
1{2 "id": 2509,3 "name": "minimize_xor",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/minimize-xor/",6 "date": "1664064000000",7 "task_description": "Given two positive integers `num1` and `num2`, find the positive integer `x` such that: `x` has the same number of set bits as `num2`, and The value `x XOR num1` is **minimal**. Note that `XOR` is the bitwise XOR operation. Return _the integer _`x`. The test cases are generated such that `x` is **uniquely determined**. The number of **set bits** of an integer is the number of `1`'s in its binary representation. **Example 1:** ``` **Input:** num1 = 3, num2 = 5 **Output:** 3 **Explanation:** The binary representations of num1 and num2 are 0011 and 0101, respectively. The integer **3** has the same number of set bits as num2, and the value `3 XOR 3 = 0` is minimal. ``` **Example 2:** ``` **Input:** num1 = 1, num2 = 12 **Output:** 3 **Explanation:** The binary representations of num1 and num2 are 0001 and 1100, respectively. The integer **3** has the same number of set bits as num2, and the value `3 XOR 1 = 2` is minimal. ``` **Constraints:** `1 <= num1, num2 <= 109`",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "num1 = 3, num2 = 5",12 "output": "3 "13 },14 {15 "label": "Example 2",16 "input": "num1 = 1, num2 = 12",17 "output": "3 "18 }19 ],20 "private_test_cases": [21 {22 "input": [23 72176727,24 77016443825 ],26 "output": 7217971127 },28 {29 "input": [30 468575171,31 2744432232 ],33 "output": 46851686434 },35 {36 "input": [37 222127838,38 59909575439 ],40 "output": 22212783641 },42 {43 "input": [44 507580866,45 28287733446 ],47 "output": 50758089548 },49 {50 "input": [51 668869429,52 94272571553 ],54 "output": 66886940855 },56 {57 "input": [58 117649255,59 77191893460 ],61 "output": 11764924862 },63 {64 "input": [65 295349101,66 62870457867 ],68 "output": 29534908869 },70 {71 "input": [72 98205273,73 23040673674 ],75 "output": 9820527276 },77 {78 "input": [79 711548599,80 86559460181 ],82 "output": 71154860783 },84 {85 "input": [86 394257872,87 8171353588 ],89 "output": 39425787290 }91 ],92 "haskell_template": "minimizeXor :: Int -> Int -> Int\nminimizeXor num1 num2 ",93 "ocaml_template": "let minimizeXor (num1: int) (num2: int) : int = ",94 "scala_template": "def minimizeXor(num1: Int,num2: Int): Int = { \n \n}",95 "java_template": "public static int minimizeXor(int num1, int num2) {\n\n}",96 "python_template": "class Solution(object):\n def minimizeXor(self, num1, num2):\n \"\"\"\n :type num1: int\n :type num2: int\n :rtype: int\n \"\"\"\n "97}