#K15896. String Similarity by Swaps

    ID: 24458 Type: Default 1000ms 256MiB

String Similarity by Swaps

String Similarity by Swaps

Given two strings s1 and s2, determine whether s1 can be transformed into s2 by performing any number of swaps between characters. In other words, check if the two strings are anagrams.

Important: The strings are considered similar if and only if:

  • Their lengths are equal, i.e. \(|s_1| = |s_2|\).
  • The multiset of characters in s1 is equal to the multiset of characters in s2, which can be mathematically written as: $$ sorted(s_1) = sorted(s_2) $$

Your task is to implement a program that reads two strings from standard input and outputs True if they are similar and False otherwise.

inputFormat

The input consists of a single line containing two non-empty strings separated by spaces.

For example:

abc bca

outputFormat

The output should be a single line: True if the two strings are similar (i.e. one can be transformed to the other by any number of swaps), or False otherwise.

## sample
abc bca
True