#K12756. Anagram Checker
Anagram Checker
Anagram Checker
In this problem, you are given two words and your task is to determine whether they are anagrams of each other. Two words are anagrams if they contain the same characters in a different order. For example, listen
and silent
are anagrams.
You may use the fact that if you sort both words, they should be identical if they are anagrams. Mathematically, for words \(word_1\) and \(word_2\), they are anagrams if \( sorted(word_1) = sorted(word_2) \).
inputFormat
The first line contains a single integer \(T\) representing the number of test cases.
For each test case, there are two lines. The first line contains the first word and the second line contains the second word. Words may contain spaces.
outputFormat
For each test case, output a single line containing YES
if the two words are anagrams, and NO
otherwise.
3
listen
silent
triangle
integral
hello
oellh
YES
YES
YES
</p>