/**
 * Given two actors, find the common movies they have acted in.
 */
fun findCommonMovies(actor1: String, actor2: String): List<String> {

    // Create a nested map to store the movies of each actor
    val actorMovies = mapOf(
        "Actor1" to mapOf(
            "Movie1" to 2005,
            "Movie2" to 2010,
            "Movie3" to 2015,
            "Movie4" to 2019
        ),
        "Actor2" to mapOf(
            "Movie1" to 2005,
            "Movie2" to 2008,
            "Movie3" to 2015,
            "Movie4" to 2021
        )
    )

    // Find the common movies by using nested loops and nested map
    val commonMovies = mutableListOf<String>()

    for ((movie1, year1) in actorMovies[actor1]!!) {
        for ((movie2, year2) in actorMovies[actor2]!!) {
            if (movie1 == movie2) {
                commonMovies.add(movie1)
            }
        }
    }

    return commonMovies
}
/**
 * Given two actors, find the common movies they have acted in.
 */
fun findCommonMovies(actor1: String, actor2: String): List<String> {
/**
 * Given two actors, find the common movies they have acted in.
 */
fun findCommonMovies(actor1: String, actor2: String): List<String> {

    // Create a nested map to store the movies of each actor
    val actorMovies = mapOf(
        "Actor1" to mapOf(
            "Movie1" to 2005,
            "Movie2" to 2010,
            "Movie3" to 2015,
            "Movie4" to 2019
        ),
        "Actor2" to mapOf(
            "Movie1" to 2005,
            "Movie2" to 2008,
            "Movie3" to 2015,
            "Movie4" to 2021
        )
    )

    // Find the common movies by using nested loops and nested map
    val commonMovies = mutableListOf<String>()

    for ((movie1, year1) in actorMovies[actor1]!!) {
        for ((movie2, year2) in actorMovies[actor2]!!) {
            if (movie1 == movie2) {
                commonMovies.add(movie1)
            }
        }
    }

    return commonMovies
}