File tree 2 files changed +27
-0
lines changed
2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * 2683. Neighboring Bitwise XOR
3
+ * https://leetcode.com/problems/neighboring-bitwise-xor/
4
+ * Difficulty: Medium
5
+ *
6
+ * A 0-indexed array derived with length n is derived by computing the bitwise XOR (⊕)
7
+ * of adjacent values in a binary array original of length n.
8
+ *
9
+ * Specifically, for each index i in the range [0, n - 1]:
10
+ * - If i = n - 1, then derived[i] = original[i] ⊕ original[0].
11
+ * - Otherwise, derived[i] = original[i] ⊕ original[i + 1].
12
+ *
13
+ * Given an array derived, your task is to determine whether there exists a valid binary
14
+ * array original that could have formed derived.
15
+ *
16
+ * Return true if such an array exists or false otherwise.
17
+ * - A binary array is an array containing only 0's and 1's
18
+ */
19
+
20
+ /**
21
+ * @param {number[] } derived
22
+ * @return {boolean }
23
+ */
24
+ var doesValidArrayExist = function ( derived ) {
25
+ return derived . reduce ( ( xor , n ) => xor ^ n , 0 ) === 0 ;
26
+ } ;
Original file line number Diff line number Diff line change 447
447
2666|[ Allow One Function Call] ( ./2666-allow-one-function-call.js ) |Easy|
448
448
2667|[ Create Hello World Function] ( ./2667-create-hello-world-function.js ) |Easy|
449
449
2677|[ Chunk Array] ( ./2677-chunk-array.js ) |Easy|
450
+ 2683|[ Neighboring Bitwise XOR] ( ./2683-neighboring-bitwise-xor.js ) |Medium|
450
451
2693|[ Call Function with Custom Context] ( ./2693-call-function-with-custom-context.js ) |Medium|
451
452
2695|[ Array Wrapper] ( ./2695-array-wrapper.js ) |Easy|
452
453
2703|[ Return Length of Arguments Passed] ( ./2703-return-length-of-arguments-passed.js ) |Easy|
You can’t perform that action at this time.
0 commit comments