2-Swap
Practice
4.2 (13 votes)
String algorithms
Hashing algorithm
Algorithms
Problem
53% Success 1477 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given two strings \(S\) and \(T\) each of length \(N\) consisting of lowercase English letters. In one operation, you can swap any two characters of \(S\) if the absolute difference between their indices is a multiple of \(2\). You may perform this operation any number of times. The absolute difference between indices \(i\) and \(j\) will be \(|i - j|\).

Print \(Yes\) if you can convert \(S\) into \(T\) after some operations else print \(No\).

Input format

  • The first line contains an integer \(T\), denoting the number of test cases.
  • The first line of each test case contains an integer \(N\), denoting the length of the string.
  • The second line of each test case contains the string \(S\).
  • The third line of each test case contains the string \(T\).

Output format

For each test case, print \(Yes\) if you can convert \(S\) into \(T\) after some operations else print \(No\) in a separate line.

Constraints

\(1 \leq T \leq 10 \\ 1 \leq N \leq 10^5 \\ \text{​S and T contains lowercase English letters​}\)

 

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
7 votes
Tags:
String AlgorithmsHashing AlgorithmAlgorithms
Points:20
Tags:
mediumEasy
Points:20
10 votes
Tags:
StringImplementationRecruitBasic ProgrammingAlgorithmsEasyString AlgorithmsApprovedHashing algorithmHashing algorithm