/**
 * Given a text and a list of words, find the characters that appear in each word of the list within the given text using loops and slicing.
 */
fun findCommonLetters(text: String, words: List<String>): Set<Char> {

    // Initialize an empty set to hold the common characters
    val commonChars = mutableSetOf<Char>()

    // Loop through each word in the list
    for (word in words) {
        // Loop through each character in the word
        for (char in word) {
            // Check if the character is also present in the text
            if (char in text) {
                // Slice the text to find the first occurrence of the character
                val index = text.indexOf(char)
                // Update the set with the common character
                commonChars.add(text[index])
            }
        }
    }

    return commonChars
}
/**
 * Given a text and a list of words, find the characters that appear in each word of the list within the given text using loops and slicing.
 */
fun findCommonLetters(text: String, words: List<String>): Set<Char> {
/**
 * Given a text and a list of words, find the characters that appear in each word of the list within the given text using loops and slicing.
 */
fun findCommonLetters(text: String, words: List<String>): Set<Char> {

    // Initialize an empty set to hold the common characters
    val commonChars = mutableSetOf<Char>()

    // Loop through each word in the list
    for (word in words) {
        // Loop through each character in the word
        for (char in word) {
            // Check if the character is also present in the text
            if (char in text) {
                // Slice the text to find the first occurrence of the character
                val index = text.indexOf(char)
                // Update the set with the common character
                commonChars.add(text[index])
            }
        }
    }

    return commonChars
}