#C13604. String Permutation Checker
String Permutation Checker
String Permutation Checker
Given two strings, determine whether they are permutations of each other. Two strings are said to be permutations if they have exactly the same characters with the same frequency in any order. The problem can be formally defined as follows:
Given two strings \( S_1 \) and \( S_2 \), check if \( S_2 \) is a permutation of \( S_1 \). In other words, \( S_1 \) and \( S_2 \) are permutations if and only if \( |S_1| = |S_2| \) and the multiset of characters in \( S_1 \) is the same as that in \( S_2 \).
Your task is to read two strings from standard input and output True
if they are permutations of each other, or False
otherwise.
inputFormat
The input consists of exactly two lines. The first line contains the first string \( S_1 \), and the second line contains the second string \( S_2 \). The strings may include letters, digits, and punctuation.
Example:
abc cab
outputFormat
Output a single line containing either True
or False
. Output True
if the two strings are permutations of each other, and False
otherwise.
Example:
True## sample
abc
cab
True