#K14646. Anagram Rearrangement Check
Anagram Rearrangement Check
Anagram Rearrangement Check
Given two strings s1 and s2, determine whether s1 can be rearranged to form s2. In other words, check if s2 is an anagram of s1. The comparison is case-sensitive and must consider all characters.
The necessary and sufficient condition is that the two strings must have identical lengths and the same frequency of each character. Formally, two strings satisfy this if and only if \( |s1| = |s2| \) and \( \operatorname{sorted}(s1) = \operatorname{sorted}(s2) \), where \( \operatorname{sorted}(s) \) denotes the string with its characters sorted in non-decreasing order.
inputFormat
The input is provided via standard input (stdin) and consists of two lines. The first line contains the string s1 and the second line contains the string s2.
outputFormat
Output a single line to standard output (stdout) containing True
if the first string can be rearranged to form the second; otherwise, output False
.
abc
abc
True
</p>