PROBLEM LINK:
Author: Yogesh Deolalkar
Tester: Ram Agrawal
Editorialist: Prathamesh Sogale
DIFFICULTY:
CAKEWALK, SIMPLE.
PREREQUISITES:
String, Math
PROBLEM:
You are given two binary strings S and P. You need to convert S into P using the following operation any number of times (possibly zero):
Pick three binary values X, Y, and Z, such that at least one of them is equal to 1 and at least one of them is equal to 0. Then, pick three distinct indices i, j, and k, and assign Si=X, Sj=Y, and Sk=Z. Determine whether it’s possible to convert S into P.
Setter's Solution
for i in range(int(input())):
n = int(input())
s = str(input())
p = str(input())
a = p.count(‘1’)
if a == n or a == 0:
if s == p:
print(“YES”)
else:
print(“NO”)
else:
print(“YES”)