#K14501. Minimum Operations to Convert Strings
Minimum Operations to Convert Strings
Minimum Operations to Convert Strings
You are given two strings s and t of equal length. Your task is to determine the minimum number of operations required to convert s into t. In one operation, you can change a single character in s so that it matches the corresponding character in t.
The number of operations needed is given by:
\( \text{operations} = \sum_{i=1}^{n} \mathbf{1}_{\{s_i \neq t_i\}} \)
where \( n \) is the length of the strings and \( \mathbf{1}_{\{s_i \neq t_i\}} \) is 1 if \( s_i \neq t_i \) and 0 otherwise.
inputFormat
The first line of input contains an integer T representing the number of test cases. Each of the following T lines contains two space-separated strings s and t of equal length.
Constraints:
- 1 ≤ T ≤ 100
- 1 ≤ length of s, t ≤ 1000
- s and t consist of lowercase English letters.
outputFormat
For each test case, output a single line in the format Case #i: result
, where i
is the test case index (starting at 1) and result
is the minimum number of operations required to convert s into t.
4
abc cba
abcd efgh
aaaa bbbb
hello hullo
Case #1: 2
Case #2: 4
Case #3: 4
Case #4: 1
</p>