/**
 * Given the name of an actor and a list of movies, find the list of co-stars
 * the actor has worked with in those movies.
 *
 * Your task is to complete the code below to solve the exercise.
 */
fun findCoStar(actor: String, movies: List<Map<String, List<String>>>): List<String> {

    val coStars = mutableListOf<String>()
    for (movie in movies) {
        if (actor in movie["cast"]!!) {
            for (coStar in movie["cast"]!!) {
                if (coStar != actor && coStar !in coStars) {
                    coStars.add(coStar)
                }
            }
        }
    }
    return coStars
}

// Example usage
/**
 * Given the name of an actor and a list of movies, find the list of co-stars
 * the actor has worked with in those movies.
 *
 * Your task is to complete the code below to solve the exercise.
 */
fun findCoStar(actor: String, movies: List<Map<String, List<String>>>): List<String> {
/**
 * Given the name of an actor and a list of movies, find the list of co-stars
 * the actor has worked with in those movies.
 *
 * Your task is to complete the code below to solve the exercise.
 */
fun findCoStar(actor: String, movies: List<Map<String, List<String>>>): List<String> {

    val coStars = mutableListOf<String>()
    for (movie in movies) {
        if (actor in movie["cast"]!!) {
            for (coStar in movie["cast"]!!) {
                if (coStar != actor && coStar !in coStars) {
                    coStars.add(coStar)
                }
            }
        }
    }
    return coStars
}

// Example usage