You are given two strings \(s\) and \(t\) of length \(n\). You can select any two positions (can be from the same or different strings) and swap the characters at those two positions. You have to perform this operation exactly once in such a way that there exists maximum one position \(i\) \((1 \le i \le n)\) such that \(s_i !=t_i\).
Determine whether it is possible to perform the operation such that the given condition holds or not.
Input format
- First line: A single integer \(T\) that denotes the number of test cases
- For each test case:
- First line: An integer \(n\)
- Next two lines: Strings \(s\) and \(t\) respectively
Output format
For each test case, print YES if a valid operation exists otherwise print NO in a single line.
Input constraints
- \(1 \le T \le 50\)
- \(1 \le n \le 10^3\)
- Both the strings \(s\) and \(t\) contain only lowercase English alphabets
In the first test case, we can get a valid result by swapping the characters \(s_3\) and \(t_8\) (1 based indexing).
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
Login to unlock the editorial
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