#C13068. Valid Anagram Checker
Valid Anagram Checker
Valid Anagram Checker
You are given two strings. Your task is to determine whether the second string is a valid anagram of the first.
An anagram is a rearrangement of the characters of one word or phrase to form another word or phrase. In this problem, you must consider only alphanumeric characters and ignore case. Formally, let \( s_1 \) and \( s_2 \) be the two strings. After removing all non-alphanumeric characters and converting each letter to lowercase, the string \( s_2 \) is a valid anagram of \( s_1 \) if and only if the frequency of each character in \( s_1 \) equals the frequency in \( s_2 \).
Special rules:
- If either of the input strings is empty, output: "Either of the input strings is empty."
- If the second string is not a valid anagram of the first, output: "The second string is not a valid anagram of the first."
- If the second string is a valid anagram of the first, output: "True"
The input will be read from standard input (stdin) and the output should be written to standard output (stdout).
inputFormat
The input consists of two lines:
- The first line contains the string \( s_1 \).
- The second line contains the string \( s_2 \).
outputFormat
Output a single line which is either:
True
if \( s_2 \) is a valid anagram of \( s_1 \).Either of the input strings is empty.
if one or both inputs are empty.The second string is not a valid anagram of the first.
if \( s_2 \) is not a valid anagram of \( s_1 \).
Listen
Silent
True