#C11179. Can Transform With K Operations
Can Transform With K Operations
Can Transform With K Operations
Given two strings s and t of equal length and an integer k, determine if it is possible to transform s into t by performing exactly k operations.
In one operation, you can change a character of s to any other character. The transformation is only possible if the exact number of mismatches (i.e. character positions where s and t differ) is equal to k. Mathematically, let the number of mismatches be:
$$ \text{diff} = \sum_{i=0}^{n-1} \mathbf{1}_{\{s_i \neq t_i\}} $$
If diff == k
, then the transformation is possible, and you should output "YES"; otherwise, output "NO".
inputFormat
The input consists of three lines from standard input:
- The first line contains the string s.
- The second line contains the string t (of equal length as s).
- The third line contains an integer k denoting the number of operations.
outputFormat
Output a single line to standard output containing "YES" if it is possible to transform s into t with exactly k operations; otherwise, output "NO".
## sampleabcde
axcye
2
YES