Skip to content

Conversation

@nirmalnishant645
Copy link
Owner

Check for most optimal solution

Comment on lines 39 to 52
def equal(arr1, arr2):
res = 0
for i in range(len(arr1)):
res ^= arr1[i]
res ^= arr2[i]
return 0 if res else 1

t = int(input())
while t > 0:
n = int(input())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
print(equal(arr1, arr2))
t -= 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if a is [1,2,1] and b is [3,2,3]

Comment on lines 39 to 44
def equal(arr1, arr2):
res1 = res2 = 0
for i in range(len(arr1)):
res1 ^= arr1[i]
res2 ^= arr2[i]
return 1 if res1 == res2 else 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if a = [1,2,2,1] and b = [3,3,4,4]

Comment on lines 42 to 43
res1 ^= arr1[i]
res2 ^= arr2[i]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need two variables for this?

@anantkaushik anantkaushik merged commit 3a15e08 into master Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants