#K62797. String Transformation Permutation
String Transformation Permutation
String Transformation Permutation
Given two strings S and T, determine whether it is possible to transform S into T by performing any number of operations. In each operation, you may remove any character from S and insert it at any position (including the beginning or end).
This is equivalent to checking if T is a permutation of S. Formally, the transformation is possible if and only if:
$$|S| = |T| \quad \text{and} \quad T \text{ is a permutation of } S.$$
If the above condition is met, output YES
; otherwise, output NO
.
inputFormat
The input is provided via standard input and consists of two lines:
- The first line contains the string S.
- The second line contains the string T.
outputFormat
Output a single line to standard output containing YES
if T can be obtained from S by any number of allowed operations, or NO
otherwise.
abc
bca
YES