Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2150b58

Browse files
committed
Add solution #2425
1 parent fb71211 commit 2150b58

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

2425-bitwise-xor-of-all-pairings.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* 2425. Bitwise XOR of All Pairings
3+
* https://leetcode.com/problems/bitwise-xor-of-all-pairings/
4+
* Difficulty: Medium
5+
*
6+
* You are given two 0-indexed arrays, nums1 and nums2, consisting of non-negative integers.
7+
* There exists another array, nums3, which contains the bitwise XOR of all pairings of
8+
* integers between nums1 and nums2 (every integer in nums1 is paired with every integer
9+
* in nums2 exactly once).
10+
*
11+
* Return the bitwise XOR of all integers in nums3.
12+
*/
13+
14+
/**
15+
* @param {number[]} nums1
16+
* @param {number[]} nums2
17+
* @return {number}
18+
*/
19+
var xorAllNums = function(nums1, nums2) {
20+
const xor = (a, b) => a.length % 2 ? b.reduce((x, y) => x ^ y): 0;
21+
return xor(nums1, nums2) ^ xor(nums2, nums1);
22+
};

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@
416416
2390|[Removing Stars From a String](./2390-removing-stars-from-a-string.js)|Medium|
417417
2396|[Strictly Palindromic Number](./2396-strictly-palindromic-number.js)|Medium|
418418
2413|[Smallest Even Multiple](./2413-smallest-even-multiple.js)|Easy|
419+
2425|[Bitwise XOR of All Pairings](./2425-bitwise-xor-of-all-pairings.js)|Medium|
419420
2427|[Number of Common Factors](./2427-number-of-common-factors.js)|Easy|
420421
2429|[Minimize XOR](./2429-minimize-xor.js)|Medium|
421422
2469|[Convert the Temperature](./2469-convert-the-temperature.js)|Easy|

0 commit comments

Comments
 (0)