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.
def axor(array):
ans = []
for i in range(len(array)-1):
ans.append((array[i] and array[i+1]) ^ (array[i] or array[i+1]) and (array[i] ^ array[i+1]))
print(max(ans))
inp = int(input())
array =[int(i) for i in input().split()]
axor(array)
I am getting problem with 4 test_cases. I unlocked few of them and found that with the above code the ans I am getting is just one lesser than the expected ans. Example: one of the test case having 20000 inputs. The expected ans is 65535 and I am getting 65534. In the same way My ans is just one lesser than the expected ans. Any help will be greatly appreciated.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
AND xor OR
You are viewing a single comment's thread. Return to all comments →
def axor(array):
ans = []
for i in range(len(array)-1):
ans.append((array[i] and array[i+1]) ^ (array[i] or array[i+1]) and (array[i] ^ array[i+1]))
print(max(ans))
inp = int(input())
array =[int(i) for i in input().split()]
axor(array)
I am getting problem with 4 test_cases. I unlocked few of them and found that with the above code the ans I am getting is just one lesser than the expected ans. Example: one of the test case having 20000 inputs. The expected ans is 65535 and I am getting 65534. In the same way My ans is just one lesser than the expected ans. Any help will be greatly appreciated.