#K37302. Taco Transformation
Taco Transformation
Taco Transformation
Given two strings s
and t
, determine whether s
can be transformed into t
by duplicating and inserting characters that already exist in s
. No new characters can be introduced during the transformation. In other words, for every character \( c \) in s
, the frequency of \( c \) in t
must be at least as high as in s
, and t
must not contain any character that does not appear in s
.
Formal Description:
Let \( f(x, c) \) denote the frequency of character \( c \) in string \( x \). The transformation is possible if and only if for every character \( c \) in s
, we have
\[
f(t, c) \ge f(s, c)\]
and for every character \( c \) in t
, \( c \) must appear in s
.
Examples:
- For
s = "abc"
andt = "aabbcc"
, the output isTrue
. - For
s = "abc"
andt = "abcd"
, the output isFalse
because a new character 'd' is introduced. - For
s = "xyz"
andt = "xyz"
, the output isTrue
.
inputFormat
The input consists of two lines. The first line contains the string s, and the second line contains the string t.
outputFormat
Output a single line containing either "True" if s can be transformed into t according to the rules, or "False" otherwise.## sample
abc
aabbcc
True