/**
 * This exercise requires the code to find the characters that are common in all the strings within a list.
 * The function takes a list of strings as an argument and returns a list of characters that are common in all strings.
 *
 * @param stringList A list of strings.
 * @return A list of characters that are common in all strings.
 *
 * Example:
 * findCommonCharacters(listOf("hello", "world")) // Output: ['l', 'o']
 */
fun findCommonCharacters(stringList: List<String>): List<Char> {

    // Check if the provided list is empty
    if (stringList.isEmpty()) {
        return emptyList()
    }

    // Initialize the list with the characters of the first string
    var commonCharacters = stringList[0].toSet()

    // Loop through each string in the list starting from the second string
    for (s in stringList.subList(1, stringList.size)) {
        // Create a set to store the common characters in the current string
        val commonCharactersInString = mutableSetOf<Char>()

        // Loop through the characters in the current string
        for (char in s) {
            // Check if the character is already in the commonCharacters set
            if (char in commonCharacters) {
                // Add the character to the commonCharactersInString set
                commonCharactersInString.add(char)
            }
        }

        // Update the commonCharacters set with the characters common in the current string
        commonCharacters = commonCharacters.intersect(commonCharactersInString)
    }

    return commonCharacters.toList()
}
/**
 * This exercise requires the code to find the characters that are common in all the strings within a list.
 * The function takes a list of strings as an argument and returns a list of characters that are common in all strings.
 *
 * @param stringList A list of strings.
 * @return A list of characters that are common in all strings.
 *
 * Example:
 * findCommonCharacters(listOf("hello", "world")) // Output: ['l', 'o']
 */
fun findCommonCharacters(stringList: List<String>): List<Char> {
/**
 * This exercise requires the code to find the characters that are common in all the strings within a list.
 * The function takes a list of strings as an argument and returns a list of characters that are common in all strings.
 *
 * @param stringList A list of strings.
 * @return A list of characters that are common in all strings.
 *
 * Example:
 * findCommonCharacters(listOf("hello", "world")) // Output: ['l', 'o']
 */
fun findCommonCharacters(stringList: List<String>): List<Char> {

    // Check if the provided list is empty
    if (stringList.isEmpty()) {
        return emptyList()
    }

    // Initialize the list with the characters of the first string
    var commonCharacters = stringList[0].toSet()

    // Loop through each string in the list starting from the second string
    for (s in stringList.subList(1, stringList.size)) {
        // Create a set to store the common characters in the current string
        val commonCharactersInString = mutableSetOf<Char>()

        // Loop through the characters in the current string
        for (char in s) {
            // Check if the character is already in the commonCharacters set
            if (char in commonCharacters) {
                // Add the character to the commonCharactersInString set
                commonCharactersInString.add(char)
            }
        }

        // Update the commonCharacters set with the characters common in the current string
        commonCharacters = commonCharacters.intersect(commonCharactersInString)
    }

    return commonCharacters.toList()
}