GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Sunday 17 July 2022

[Solution] Consecutive XOR Codechef Solution


Chef has two binary strings A and B, both having length N. He can perform the following operation on A any number of times (possibly zero):

  • Select any index i (1iN1) and simultaneously set Ai:=AiAi+1 and Ai+1:=AiAi+1. Formally, if initially Ai=x and Ai+1=y then set Ai:=xy and Ai+1:=xy

Here,  denotes the bitwise XOR operation.

Chef wants to determine if it is possible to make A equal to B by applying the above operation any number of

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

times. Can you help Chef?

Input Format

  • The first line contains a single integer T — the number of test cases. Then the test cases follow.
  • The first line of each test case contains an integer N — the length of the binary string A.
  • The second line of each test case contains the binary string A of length N.
  • The third line of each test case contains the binary string B of length N.

Output Format

For each test case, output YES if Chef can make string A equal to string B by applying the above operation any number of times. Otherwise, output NO.

You may print each character of YES and NO in uppercase or lowercase (for example, yesyEsYes will be considered identical).

Constraints

  • 1T105
  • 2N105
  • The sum of N over all test cases does not exceed 

No comments:

Post a Comment