We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d11aabe commit 1391259Copy full SHA for 1391259
2601-2700/2683_neighboring_bitwise_xor.rb
@@ -1,5 +1,8 @@
1
# @param {Integer[]} derived
2
# @return {Boolean}
3
def does_valid_array_exist(derived)
4
+ # assume the original is [a,b,c,d]
5
+ # the derived will be: [(a^b),(b^c),(c^d),(d^a)]
6
+ # hence the xor-sum (a^b^b^c^c^d^d^a) will be zero
7
derived.reduce(&:^).zero?
8
end
0 commit comments