#K35942. String Transformation Possibility
String Transformation Possibility
String Transformation Possibility
You are given a string s
and an integer k
. The task is to determine whether it is possible to transform s
into a string of length k
by duplicating characters. In other words, you may duplicate any character in s
any number of times (including zero) such that the final string has exactly k
characters. Note that you are not allowed to remove any character from s
.
The transformation is possible if and only if the original length of s
is less than or equal to k
. If the length of s
is already greater than k
, then the transformation is impossible.
Formally, let \(n = |s|\). The answer is "YES" if \(n \le k\) and "NO" otherwise.
inputFormat
The input is read from standard input. The first line contains an integer T
representing the number of test cases. Each of the following T
lines contains a string s
and an integer k
separated by a space.
outputFormat
For each test case, print "YES" if it is possible to transform s
into a string of length k
by duplicating characters, and "NO" otherwise. Each answer should be on a new line on standard output.
4
abc 7
hello 5
world 10
code 3
YES
YES
YES
NO
</p>