Skip to content

Commit 0d80bcf

Browse files
authored
Create chalkboard-xor-gam.cpp
1 parent 65d1096 commit 0d80bcf

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

C++/chalkboard-xor-gam.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Time: O(n)
2+
// Space: O(1)
3+
4+
class Solution {
5+
public:
6+
bool xorGame(vector<int>& nums) {
7+
return accumulate(nums.cbegin(), nums.cend(),
8+
0, std::bit_xor<int>()) == 0 ||
9+
nums.size() % 2 == 0;
10+
}
11+
};

0 commit comments

Comments
 (0)