Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c38b9e2

Browse files
feat: add solutions to lc problem: No.2683 (doocs#4607)
No.2683.Neighboring Bitwise XOR
1 parent ee8884b commit c38b9e2

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed

‎solution/2600-2699/2683.Neighboring Bitwise XOR/README.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,38 @@ function doesValidArrayExist(derived: number[]): boolean {
160160
}
161161
```
162162

163+
#### Rust
164+
165+
```rust
166+
impl Solution {
167+
pub fn does_valid_array_exist(derived: Vec<i32>) -> bool {
168+
derived.iter().fold(0, |acc, &x| acc ^ x) == 0
169+
}
170+
}
171+
```
172+
173+
#### JavaScript
174+
175+
```js
176+
/**
177+
* @param {number[]} derived
178+
* @return {boolean}
179+
*/
180+
var doesValidArrayExist = function (derived) {
181+
return derived.reduce((acc, x) => acc ^ x) === 0;
182+
};
183+
```
184+
185+
#### C#
186+
187+
```cs
188+
public class Solution {
189+
public bool DoesValidArrayExist(int[] derived) {
190+
return derived.Aggregate(0, (acc, x) => acc ^ x) == 0;
191+
}
192+
}
193+
```
194+
163195
<!-- tabs:end -->
164196

165197
<!-- solution:end -->

‎solution/2600-2699/2683.Neighboring Bitwise XOR/README_EN.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,38 @@ function doesValidArrayExist(derived: number[]): boolean {
161161
}
162162
```
163163

164+
#### Rust
165+
166+
```rust
167+
impl Solution {
168+
pub fn does_valid_array_exist(derived: Vec<i32>) -> bool {
169+
derived.iter().fold(0, |acc, &x| acc ^ x) == 0
170+
}
171+
}
172+
```
173+
174+
#### JavaScript
175+
176+
```js
177+
/**
178+
* @param {number[]} derived
179+
* @return {boolean}
180+
*/
181+
var doesValidArrayExist = function (derived) {
182+
return derived.reduce((acc, x) => acc ^ x) === 0;
183+
};
184+
```
185+
186+
#### C#
187+
188+
```cs
189+
public class Solution {
190+
public bool DoesValidArrayExist(int[] derived) {
191+
return derived.Aggregate(0, (acc, x) => acc ^ x) == 0;
192+
}
193+
}
194+
```
195+
164196
<!-- tabs:end -->
165197

166198
<!-- solution:end -->
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public class Solution {
2+
public bool DoesValidArrayExist(int[] derived) {
3+
return derived.Aggregate(0, (acc, x) => acc ^ x) == 0;
4+
}
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @param {number[]} derived
3+
* @return {boolean}
4+
*/
5+
var doesValidArrayExist = function (derived) {
6+
return derived.reduce((acc, x) => acc ^ x) === 0;
7+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
impl Solution {
2+
pub fn does_valid_array_exist(derived: Vec<i32>) -> bool {
3+
derived.iter().fold(0, |acc, &x| acc ^ x) == 0
4+
}
5+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /