We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defsumXor(n):# So basically, criteria is met when all bits are flipped to 1's for an n xor x #and none are flipped to zeros#Meaning any non-1 in n is an option for x values, fortunately x is never greater than n making#this a lot easierifn==0:return1return2**sum([Trueifi=='0'elseFalseforiinformat(n,'0b')])
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sum vs XOR
You are viewing a single comment's thread. Return to all comments →