String Sorted
Time Limit: 1.0 s
Memory Limit: 256.0 MB
Description
You are given two strings S and P; the length of both strings is equal, which is N.
You can perform the following operations as many times as you wish:
- Choose an index \(i\), \(1<=i<=N\), and swap their characters.(Ex. swap (\(S[i] , P[i]\)) )
Your goal is to make at least one of the strings sorted.
string "abc" and "bbbpp" are sorted, while string "babc", "zaab" are not.
Input
First line T, the number of test cases.
In each test case, First line N, the length of the both strings.
Second line, a string S.
Third line, a string P.
\(1<=T<=10^4\)
\(1<=N<=10^5\)
String S and P contains only lowercase english alphabets.
Sum of N overall test case doesn't exceed \(10^5\).
Output
In each test case, print Yes ,if one of the strings make sorted, otherwise pirnt No.
Sample
Input | Output |
---|---|
|
|
First test case,
String S = "pcc" and P = "acb",
Choose index 1, and swap their character.
After swap, String S = "acc" and P = "pcb".
string S is sorted.
Information
- ID
- 1117
- Difficulty
- 1
- Category
- (None)
- Tags
- (None)
- # Submissions
- 62
- Accepted
- 19
- Accepted Ratio
- 31%
- Uploaded By