#K90517. Maximum Possible Distance After Transformation
Maximum Possible Distance After Transformation
Maximum Possible Distance After Transformation
You are given two equal-length strings S and T. You are allowed to perform exactly one transformation, which consists of swapping a single character from S with a single character from T. The distance between the two strings is defined as the number of positions where the characters in S and T are the same. In other words, if S and T have length n, then the distance is given by:
$$\text{distance} = \sum_{i=0}^{n-1}\mathbf{1}(S_i = T_i)$$
Your task is to determine the maximum possible distance that can be achieved by performing one such swap transformation. Additionally, you must process multiple test cases.
Note: The strings S and T are guaranteed to have the same length.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer T, the number of test cases.
- For each test case, there are two subsequent lines:
- The first line is the string S.
- The second line is the string T.
Both S and T are of equal length.
outputFormat
For each test case, output the maximum possible distance (i.e., the maximum number of matching positions after performing one swap transformation) on a separate line to standard output (stdout).## sample
2
abcde
fghij
abc
aba
0
2
</p>