/**
 * Given two lists of actor/actress names, find the common characters in both lists.
 *
 * @param names1 The first list of actor/actress names.
 * @param names2 The second list of actor/actress names.
 * @return A list of common characters.
 *
 * Examples:
 * findCommonCharacters(listOf("Robert Downey Jr.", "Chris Evans", "Scarlett Johansson"),
 *                      listOf("Chris Hemsworth", "Scarlett Johansson", "Chris Pratt"))
 * // Output: ['a', 's', 'c', 't', 'r', 'J', 'o', 'h', 'n', 's']
 *
 * findCommonCharacters(listOf("Leonardo DiCaprio", "Brad Pitt", "Joaquin Phoenix"),
 *                      listOf("Tom Hanks", "Saoirse Ronan", "Bradley Cooper"))
 * // Output: []
 */
fun findCommonCharacters(names1: List<String>, names2: List<String>): List<Char> {

    val characters1 = mutableSetOf<Char>()
    val characters2 = mutableSetOf<Char>()

    names1.forEach { name ->
        characters1.addAll(name.toLowerCase().toSet())
    }

    names2.forEach { name ->
        characters2.addAll(name.toLowerCase().toSet())
    }

    val commonCharacters = characters1.intersect(characters2)

    return commonCharacters.toList()
}
/**
 * Given two lists of actor/actress names, find the common characters in both lists.
 *
 * @param names1 The first list of actor/actress names.
 * @param names2 The second list of actor/actress names.
 * @return A list of common characters.
 *
 * Examples:
 * findCommonCharacters(listOf("Robert Downey Jr.", "Chris Evans", "Scarlett Johansson"),
 *                      listOf("Chris Hemsworth", "Scarlett Johansson", "Chris Pratt"))
 * // Output: ['a', 's', 'c', 't', 'r', 'J', 'o', 'h', 'n', 's']
 *
 * findCommonCharacters(listOf("Leonardo DiCaprio", "Brad Pitt", "Joaquin Phoenix"),
 *                      listOf("Tom Hanks", "Saoirse Ronan", "Bradley Cooper"))
 * // Output: []
 */
fun findCommonCharacters(names1: List<String>, names2: List<String>): List<Char> {
/**
 * Given two lists of actor/actress names, find the common characters in both lists.
 *
 * @param names1 The first list of actor/actress names.
 * @param names2 The second list of actor/actress names.
 * @return A list of common characters.
 *
 * Examples:
 * findCommonCharacters(listOf("Robert Downey Jr.", "Chris Evans", "Scarlett Johansson"),
 *                      listOf("Chris Hemsworth", "Scarlett Johansson", "Chris Pratt"))
 * // Output: ['a', 's', 'c', 't', 'r', 'J', 'o', 'h', 'n', 's']
 *
 * findCommonCharacters(listOf("Leonardo DiCaprio", "Brad Pitt", "Joaquin Phoenix"),
 *                      listOf("Tom Hanks", "Saoirse Ronan", "Bradley Cooper"))
 * // Output: []
 */
fun findCommonCharacters(names1: List<String>, names2: List<String>): List<Char> {

    val characters1 = mutableSetOf<Char>()
    val characters2 = mutableSetOf<Char>()

    names1.forEach { name ->
        characters1.addAll(name.toLowerCase().toSet())
    }

    names2.forEach { name ->
        characters2.addAll(name.toLowerCase().toSet())
    }

    val commonCharacters = characters1.intersect(characters2)

    return commonCharacters.toList()
}