#K93577. Anagram Checker
Anagram Checker
Anagram Checker
You are given two strings. Your task is to determine whether the characters of one string can be rearranged to form the other string. In other words, check if the two strings are anagrams of each other.
Formally, let \( a \) and \( b \) be the two input strings. If
[ \text{sorted}(a) = \text{sorted}(b), ]
then the output should be YES
; otherwise, it should be NO
.
For example, the strings "listen" and "silent" are anagrams, whereas "hello" and "world" are not.
inputFormat
The input consists of two non-empty strings provided on separate lines. Each string may contain any visible characters.
Line 1: string a Line 2: string b
outputFormat
Output a single line containing YES
if the two strings are anagrams of each other, and NO
otherwise.
listen
silent
YES