#C6981. Check if Two Strings are Permutations
Check if Two Strings are Permutations
Check if Two Strings are Permutations
Given two strings s1 and s2, determine whether one string is a permutation of the other. In other words, check if rearranging the characters of s1 can result in s2. Two strings are considered permutations if their sorted sequences are identical. Note that two empty strings are also considered permutations.
The problem can be mathematically formulated as follows:
Let \( s1 = a_1a_2...a_n \) and \( s2 = b_1b_2...b_m \). We have \( s1 \) is a permutation of \( s2 \) if and only if \( n = m \) and \( sorted(s1) = sorted(s2) \).
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 can be empty and will consist of ASCII characters.
outputFormat
Output a single line containing either True
if the second string is a permutation of the first, or False
otherwise.
abc
cba
True