/**
 * This function takes in two strings representing the names of an actor and an actress
 * and returns a list containing the letters that are common to both names,
 * in the exact order they appear in the actor's name.
 *
 * Example:
 * actorName = "Leonardo DiCaprio"
 * actressName = "Kate Winslet"
 * output -> ['L', 'e', 'o']
 */
fun findCommonLetters(actorName: String, actressName: String): List<Char> {

    // Convert names to lowercase for case-insensitive comparison
    var actorNameLower = actorName.toLowerCase()
    var actressNameLower = actressName.toLowerCase()

    val commonLetters = mutableListOf<Char>()

    // Loop through each character in the actor's name
    for (char in actorNameLower) {
        // Check if the character is present in the actress's name and not already in the commonLetters list
        if (char in actressNameLower && char !in commonLetters) {
            commonLetters.add(char)
        }
    }

    return commonLetters
}
/**
 * This function takes in two strings representing the names of an actor and an actress
 * and returns a list containing the letters that are common to both names,
 * in the exact order they appear in the actor's name.
 *
 * Example:
 * actorName = "Leonardo DiCaprio"
 * actressName = "Kate Winslet"
 * output -> ['L', 'e', 'o']
 */
fun findCommonLetters(actorName: String, actressName: String): List<Char> {
/**
 * This function takes in two strings representing the names of an actor and an actress
 * and returns a list containing the letters that are common to both names,
 * in the exact order they appear in the actor's name.
 *
 * Example:
 * actorName = "Leonardo DiCaprio"
 * actressName = "Kate Winslet"
 * output -> ['L', 'e', 'o']
 */
fun findCommonLetters(actorName: String, actressName: String): List<Char> {

    // Convert names to lowercase for case-insensitive comparison
    var actorNameLower = actorName.toLowerCase()
    var actressNameLower = actressName.toLowerCase()

    val commonLetters = mutableListOf<Char>()

    // Loop through each character in the actor's name
    for (char in actorNameLower) {
        // Check if the character is present in the actress's name and not already in the commonLetters list
        if (char in actressNameLower && char !in commonLetters) {
            commonLetters.add(char)
        }
    }

    return commonLetters
}