Skip to content

Commit 6674bc6

Browse files
committed
Add solution #2317
1 parent 68fe034 commit 6674bc6

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 1,879 LeetCode solutions in JavaScript
1+
# 1,880 LeetCode solutions in JavaScript
22

33
[https://leetcodejavascript.com](https://leetcodejavascript.com)
44

@@ -1759,6 +1759,7 @@
17591759
2312|[Selling Pieces of Wood](./solutions/2312-selling-pieces-of-wood.js)|Hard|
17601760
2315|[Count Asterisks](./solutions/2315-count-asterisks.js)|Easy|
17611761
2316|[Count Unreachable Pairs of Nodes in an Undirected Graph](./solutions/2316-count-unreachable-pairs-of-nodes-in-an-undirected-graph.js)|Medium|
1762+
2317|[Maximum XOR After Operations](./solutions/2317-maximum-xor-after-operations.js)|Medium|
17621763
2336|[Smallest Number in Infinite Set](./solutions/2336-smallest-number-in-infinite-set.js)|Medium|
17631764
2338|[Count the Number of Ideal Arrays](./solutions/2338-count-the-number-of-ideal-arrays.js)|Hard|
17641765
2342|[Max Sum of a Pair With Equal Sum of Digits](./solutions/2342-max-sum-of-a-pair-with-equal-sum-of-digits.js)|Medium|
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* 2317. Maximum XOR After Operations
3+
* https://leetcode.com/problems/maximum-xor-after-operations/
4+
* Difficulty: Medium
5+
*
6+
* You are given a 0-indexed integer array nums. In one operation, select any non-negative
7+
* integer x and an index i, then update nums[i] to be equal to nums[i] AND (nums[i] XOR x).
8+
*
9+
* Note that AND is the bitwise AND operation and XOR is the bitwise XOR operation.
10+
*
11+
* Return the maximum possible bitwise XOR of all elements of nums after applying the operation
12+
* any number of times.
13+
*/
14+
15+
/**
16+
* @param {number[]} nums
17+
* @return {number}
18+
*/
19+
var maximumXOR = function(nums) {
20+
let maxXor = 0;
21+
22+
for (const num of nums) {
23+
maxXor |= num;
24+
}
25+
26+
return maxXor;
27+
};

0 commit comments

Comments
 (0)