#K36142. Anagram Checker
Anagram Checker
Anagram Checker
You are given a list of strings. Your task is to determine whether all the strings in the list are anagrams of each other. Two strings are anagrams if they contain the same characters with the exact same frequencies. The comparison is case-sensitive and spaces are treated as characters.
The input begins with an integer n which denotes the number of strings. If n is 0, output False
. For n greater than 0, read the next n lines each containing a string. If there is only one string, output True
because a single string is trivially an anagram of itself.
Determine if every string is an anagram of the first string and output True
if they are, or False
otherwise.
inputFormat
The first line contains an integer n (n ≥ 0), indicating the number of strings. Each of the next n lines contains a non-empty string. The strings may include spaces and are case-sensitive.
outputFormat
Output a single line with either True
or False
. Print True
if all the strings are anagrams of the first string; otherwise, print False
.
0
False