#C6028. Contains Anagram
Contains Anagram
Contains Anagram
Given a list of strings, determine if there exists at least one pair of strings that are anagrams of each other. Two strings are anagrams if one can be rearranged to form the other, for example, listen and silent. The input format is the number of strings followed by the strings themselves, one per line. Output True
if any such pair exists, and False
otherwise.
The problem can be mathematically formulated as follows: Given a set of strings \( S = \{s_1, s_2, \ldots, s_n\} \), determine if \( \exists\; i\neq j \) such that \( sort(s_i)=sort(s_j) \) where \( sort(s) \) denotes the string after sorting its characters in lexicographical order.
inputFormat
Input is given via standard input (stdin). The first line contains a non-negative integer n representing the number of strings. The following n lines each contain a string.
outputFormat
Output a single line to standard output (stdout) containing either True
or False
. True
indicates that there exists at least one pair of strings which are anagrams of each other, otherwise output False
.
0
False
</p>