/**
 * This function takes a list of names as input and returns a set containing the characters 
 * that are commonly found in all the names.
 *
 * @param names A list of names.
 * @return A set containing the common characters found in all names.
 */
fun findCommonCharacters(names: List<String>): Set<Char> {

    // Check if the names list is empty
    if (names.isEmpty()) {
        return emptySet()
    }

    // Initialize the commonChars set with all characters from the first name
    var commonChars = names[0].toSet()

    // Iterate over each name starting from the second one
    for (name in names.subList(1, names.size)) {
        // Create a temporary set to store the characters in the current name
        val currentChars = mutableSetOf<Char>()

        // Iterate over each character in the current name
        for (char in name) {
            // Check if the character is present in the commonChars set
            if (char in commonChars) {
                // Add the character to the temporary set
                currentChars.add(char)
            }
        }

        // Update the commonChars set with the characters that are common in both the sets
        commonChars = commonChars.intersect(currentChars)
    }

    return commonChars
}
/**
 * This function takes a list of names as input and returns a set containing the characters 
 * that are commonly found in all the names.
 *
 * @param names A list of names.
 * @return A set containing the common characters found in all names.
 */
fun findCommonCharacters(names: List<String>): Set<Char> {
/**
 * This function takes a list of names as input and returns a set containing the characters 
 * that are commonly found in all the names.
 *
 * @param names A list of names.
 * @return A set containing the common characters found in all names.
 */
fun findCommonCharacters(names: List<String>): Set<Char> {

    // Check if the names list is empty
    if (names.isEmpty()) {
        return emptySet()
    }

    // Initialize the commonChars set with all characters from the first name
    var commonChars = names[0].toSet()

    // Iterate over each name starting from the second one
    for (name in names.subList(1, names.size)) {
        // Create a temporary set to store the characters in the current name
        val currentChars = mutableSetOf<Char>()

        // Iterate over each character in the current name
        for (char in name) {
            // Check if the character is present in the commonChars set
            if (char in commonChars) {
                // Add the character to the temporary set
                currentChars.add(char)
            }
        }

        // Update the commonChars set with the characters that are common in both the sets
        commonChars = commonChars.intersect(currentChars)
    }

    return commonChars
}