/**
 * Determines if two words are anagrams of each other.
 *
 * @param word1 The first word.
 * @param word2 The second word.
 * @return True if the words are anagrams, False otherwise.
 */
fun checkAnagram(word1: String, word2: String): Boolean {

    // Convert both words to lowercase
    var word1 = word1.toLowerCase()
    var word2 = word2.toLowerCase()

    // Remove any whitespaces from the words
    word1 = word1.replace("\\s".toRegex(), "")
    word2 = word2.replace("\\s".toRegex(), "")

    if (word1.length != word2.length) {
        return false
    }

    // Create maps to store frequency of characters in each word
    val freq1 = mutableMapOf<Char, Int>()
    val freq2 = mutableMapOf<Char, Int>()

    for (char in word1) {
        freq1[char] = freq1.getOrDefault(char, 0) + 1
    }

    for (char in word2) {
        freq2[char] = freq2.getOrDefault(char, 0) + 1
    }

    // Check if the frequency maps are equal
    return freq1 == freq2
}
/**
 * Determines if two words are anagrams of each other.
 *
 * @param word1 The first word.
 * @param word2 The second word.
 * @return True if the words are anagrams, False otherwise.
 */
fun checkAnagram(word1: String, word2: String): Boolean {
/**
 * Determines if two words are anagrams of each other.
 *
 * @param word1 The first word.
 * @param word2 The second word.
 * @return True if the words are anagrams, False otherwise.
 */
fun checkAnagram(word1: String, word2: String): Boolean {

    // Convert both words to lowercase
    var word1 = word1.toLowerCase()
    var word2 = word2.toLowerCase()

    // Remove any whitespaces from the words
    word1 = word1.replace("\\s".toRegex(), "")
    word2 = word2.replace("\\s".toRegex(), "")

    if (word1.length != word2.length) {
        return false
    }

    // Create maps to store frequency of characters in each word
    val freq1 = mutableMapOf<Char, Int>()
    val freq2 = mutableMapOf<Char, Int>()

    for (char in word1) {
        freq1[char] = freq1.getOrDefault(char, 0) + 1
    }

    for (char in word2) {
        freq2[char] = freq2.getOrDefault(char, 0) + 1
    }

    // Check if the frequency maps are equal
    return freq1 == freq2
}