#K1251. Permutation Checker
Permutation Checker
Permutation Checker
Given two strings, determine if one string is a permutation of the other. Two strings are considered permutations if they contain exactly the same characters with the same frequency. If the strings have different lengths, they cannot be permutations.
For example, if the input strings are abc
and bca
, then the output should be Yes
because bca
is a permutation of abc
. Conversely, if one string contains extra characters, the output should be No
.
The solution should read input from standard input (stdin) and write the output to standard output (stdout). Use efficient methods to ensure your solution is optimal.
inputFormat
The input consists of two lines. The first line contains the first string s1 and the second line contains the second string s2. Both strings consist of printable characters.
outputFormat
Output a single line that contains either Yes
or No
. Output Yes
if the two strings are permutations of each other, and No
otherwise.
abc
bca
Yes