/**
 * Given a list of actor/actress names, find the common letters between all the names.
 *
 * @param names A list of strings representing actor/actress names.
 * @return A set containing the common letters found in all the names.
 *
 * Example:
 * findCommonLetters(listOf("Brad Pitt", "Angelina Jolie", "Leonardo DiCaprio")) // Output: setOf('a', 'i')
 * findCommonLetters(listOf("Tom Hanks", "Robert De Niro", "Scarlett Johansson")) // Output: setOf(' ', 'o')
 */
fun findCommonLetters(names: List<String>): Set<Char> {

    var commonLetters = names[0].toSet() // Initialize the set with the letters from the first name

    for (name in names.subList(1, names.size)) {
        commonLetters = commonLetters.intersect(name.toSet()) // Find the intersection of the current name and commonLetters
    }

    return commonLetters
}
/**
 * Given a list of actor/actress names, find the common letters between all the names.
 *
 * @param names A list of strings representing actor/actress names.
 * @return A set containing the common letters found in all the names.
 *
 * Example:
 * findCommonLetters(listOf("Brad Pitt", "Angelina Jolie", "Leonardo DiCaprio")) // Output: setOf('a', 'i')
 * findCommonLetters(listOf("Tom Hanks", "Robert De Niro", "Scarlett Johansson")) // Output: setOf(' ', 'o')
 */
fun findCommonLetters(names: List<String>): Set<Char> {
/**
 * Given a list of actor/actress names, find the common letters between all the names.
 *
 * @param names A list of strings representing actor/actress names.
 * @return A set containing the common letters found in all the names.
 *
 * Example:
 * findCommonLetters(listOf("Brad Pitt", "Angelina Jolie", "Leonardo DiCaprio")) // Output: setOf('a', 'i')
 * findCommonLetters(listOf("Tom Hanks", "Robert De Niro", "Scarlett Johansson")) // Output: setOf(' ', 'o')
 */
fun findCommonLetters(names: List<String>): Set<Char> {

    var commonLetters = names[0].toSet() // Initialize the set with the letters from the first name

    for (name in names.subList(1, names.size)) {
        commonLetters = commonLetters.intersect(name.toSet()) // Find the intersection of the current name and commonLetters
    }

    return commonLetters
}