Skip to content

Commit 1e5e46a

Browse files
committed
feat: add typescript solution to lc problem: No.2425
No.2425.Bitwise XOR of All Pairings
1 parent 069933e commit 1e5e46a

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

solution/2400-2499/2425.Bitwise XOR of All Pairings/README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,16 @@ func xorAllNums(nums1 []int, nums2 []int) int {
142142
### **TypeScript**
143143

144144
```ts
145-
145+
function xorAllNums(nums1: number[], nums2: number[]): number {
146+
let ans = 0;
147+
if (nums2.length % 2 != 0) {
148+
ans ^= nums1.reduce((a, c) => a ^ c, 0);
149+
}
150+
if (nums1.length % 2 != 0) {
151+
ans ^= nums2.reduce((a, c) => a ^ c, 0);
152+
}
153+
return ans;
154+
};
146155
```
147156

148157
### **...**

solution/2400-2499/2425.Bitwise XOR of All Pairings/README_EN.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,16 @@ func xorAllNums(nums1 []int, nums2 []int) int {
123123
### **TypeScript**
124124

125125
```ts
126-
126+
function xorAllNums(nums1: number[], nums2: number[]): number {
127+
let ans = 0;
128+
if (nums2.length % 2 != 0) {
129+
ans ^= nums1.reduce((a, c) => a ^ c, 0);
130+
}
131+
if (nums1.length % 2 != 0) {
132+
ans ^= nums2.reduce((a, c) => a ^ c, 0);
133+
}
134+
return ans;
135+
};
127136
```
128137

129138
### **...**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function xorAllNums(nums1: number[], nums2: number[]): number {
2+
let ans = 0;
3+
if (nums2.length % 2 != 0) {
4+
ans ^= nums1.reduce((a, c) => a ^ c, 0);
5+
}
6+
if (nums1.length % 2 != 0) {
7+
ans ^= nums2.reduce((a, c) => a ^ c, 0);
8+
}
9+
return ans;
10+
};

0 commit comments

Comments
 (0)