#K80367. Anagram Checker
Anagram Checker
Anagram Checker
Given a list of strings, determine if all strings are anagrams of each other. Two strings are anagrams if they contain the same characters in any order. If the list is empty, consider it as not forming an anagram group.
More formally, let \(S = \{s_1, s_2, \dots, s_n\}\) be the set of strings. Each string \(s\) can be transformed into a canonical form \(f(s)\) by sorting its characters. The strings are all anagrams if and only if \(f(s_1) = f(s_2) = \dots = f(s_n)\). Output Yes
if this condition holds, otherwise output No
.
inputFormat
The input is given via standard input (stdin) with multiple lines. The first line contains an integer \(n\) indicating the number of strings. Each of the next \(n\) lines contains a single string.
outputFormat
Output a single line to standard output (stdout). Print Yes
if all strings are anagrams of each other, and No
otherwise.
3
listen
silent
enlist
Yes