/**
 * Given two words, find and return a sorted set of common characters between them.
 *
 * @param word1 The first word.
 * @param word2 The second word.
 * @return A sorted set of common characters from both words.
 */
fun findCommonCharacters(word1: String, word2: String): Set<Char> {

    val commonChars = mutableSetOf<Char>()
    var index = 0

    while (index < word1.length) {
        if (word1[index] in word2) {
            commonChars.add(word1[index])
        }
        index++
    }

    return commonChars.toSortedSet()
}
/**
 * Given two words, find and return a sorted set of common characters between them.
 *
 * @param word1 The first word.
 * @param word2 The second word.
 * @return A sorted set of common characters from both words.
 */
fun findCommonCharacters(word1: String, word2: String): Set<Char> {
/**
 * Given two words, find and return a sorted set of common characters between them.
 *
 * @param word1 The first word.
 * @param word2 The second word.
 * @return A sorted set of common characters from both words.
 */
fun findCommonCharacters(word1: String, word2: String): Set<Char> {

    val commonChars = mutableSetOf<Char>()
    var index = 0

    while (index < word1.length) {
        if (word1[index] in word2) {
            commonChars.add(word1[index])
        }
        index++
    }

    return commonChars.toSortedSet()
}