#K40667. Equal String Rearrangement

    ID: 26694 Type: Default 1000ms 256MiB

Equal String Rearrangement

Equal String Rearrangement

Given two strings \(A\) and \(B\), determine whether it is possible to make them equal by rearranging the characters within each string any number of times. In other words, you are allowed to perform any number of swaps within the same string. The strings can be made equal if and only if they have the same characters with identical frequencies.

Note: The rearrangement is done independently for each string. Thus, if the sorted sequences of characters in both strings are equal, then the answer is "True"; otherwise, it is "False".

For instance, consider \(A = 'abac'\) and \(B = 'bcaa'\). After sorting, both become \(aabc\), so the answer is True. However, for \(A = 'abcd'\) and \(B = 'efgh'\), the sorted strings are different, and hence the answer is False.

inputFormat

The input consists of exactly two lines. The first line contains the string (A) and the second line contains the string (B). Both strings are non-empty and contain only lowercase English letters.

outputFormat

Output a single line containing True if it is possible to rearrange the characters within each string to make them equal, otherwise output False.## sample

abac
bcaa
True