Skip to content

Commit 826fc77

Browse files
committed
Jan 16
1 parent 4525150 commit 826fc77

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from functools import reduce
2+
from operator import xor
3+
from typing import List
4+
5+
6+
class Solution:
7+
def xorAllNums(self, nums1: List[int], nums2: List[int]) -> int:
8+
x = 0
9+
if len(nums1) & 1 != 0:
10+
x = reduce(xor, nums2)
11+
if len(nums2) & 1 != 0:
12+
x ^= reduce(xor, nums1)
13+
return x
14+
15+
16+
def main():
17+
nums1 = [2, 1, 3]
18+
nums2 = [10, 2, 5, 0]
19+
assert Solution().xorAllNums(nums1, nums2) == 13
20+
21+
nums1 = [1, 2]
22+
nums2 = [3, 4]
23+
assert Solution().xorAllNums(nums1, nums2) == 0
24+
25+
26+
if __name__ == '__main__':
27+
main()

2025-01-January-LeetCoding-Challenge/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
| January 13 | [3223. Minimum Length of String After Operations](https://leetcode.com/problems/minimum-length-of-string-after-operations/) | Medium | Solved |
1919
| January 14 | [2657. Find the Prefix Common Array of Two Arrays](https://leetcode.com/problems/find-the-prefix-common-array-of-two-arrays/) | Medium | Solved |
2020
| January 15 | [2429. Minimize XOR](https://leetcode.com/problems/minimize-xor/) | Medium | Unsolved |
21-
| January 16 | []() | | |
21+
| January 16 | [2425. Bitwise XOR of All Pairings](https://leetcode.com/problems/bitwise-xor-of-all-pairings/) | Medium | Solved |
2222
| January 17 | []() | | |
2323
| January 18 | []() | | |
2424
| January 19 | []() | | |
@@ -40,5 +40,5 @@
4040
| Level | Problems | Solved | Unsolved |
4141
| --- | --- | --- | --- |
4242
| Easy | 4 | 4 | 0 |
43-
| Medium | 11 | 9 | 2 |
43+
| Medium | 12 | 10 | 2 |
4444
| Hard | 0 | 0 | 0 |

0 commit comments

Comments
 (0)