/**
 * Geographer Exercise:
 *
 * You are given two lists of countries.
 * Write a function that returns a new list containing the countries that are common in both lists.
 *
 * @param countries1 A list of countries
 * @param countries2 A list of countries
 * @return A list of countries common to both input lists
 *
 * Example:
 * findCommonCountries(listOf("USA", "Canada", "Italy", "Mexico"), listOf("Russia", "Brazil", "USA", "Italy")) // Output: ["USA", "Italy"]
 * findCommonCountries(listOf("Australia", "Japan", "Germany"), listOf("India", "Sweden", "Canada")) // Output: []
 */
fun findCommonCountries(countries1: List<String>, countries2: List<String>): List<String> {

    val commonCountries = mutableListOf<String>()

    // Using a for loop to iterate over countries in the first list
    for (country in countries1) {
        // Checking if the country is present in the second list
        if (country in countries2) {
            commonCountries.add(country)
        }
    }

    return commonCountries
}
/**
 * Geographer Exercise:
 *
 * You are given two lists of countries.
 * Write a function that returns a new list containing the countries that are common in both lists.
 *
 * @param countries1 A list of countries
 * @param countries2 A list of countries
 * @return A list of countries common to both input lists
 *
 * Example:
 * findCommonCountries(listOf("USA", "Canada", "Italy", "Mexico"), listOf("Russia", "Brazil", "USA", "Italy")) // Output: ["USA", "Italy"]
 * findCommonCountries(listOf("Australia", "Japan", "Germany"), listOf("India", "Sweden", "Canada")) // Output: []
 */
fun findCommonCountries(countries1: List<String>, countries2: List<String>): List<String> {
/**
 * Geographer Exercise:
 *
 * You are given two lists of countries.
 * Write a function that returns a new list containing the countries that are common in both lists.
 *
 * @param countries1 A list of countries
 * @param countries2 A list of countries
 * @return A list of countries common to both input lists
 *
 * Example:
 * findCommonCountries(listOf("USA", "Canada", "Italy", "Mexico"), listOf("Russia", "Brazil", "USA", "Italy")) // Output: ["USA", "Italy"]
 * findCommonCountries(listOf("Australia", "Japan", "Germany"), listOf("India", "Sweden", "Canada")) // Output: []
 */
fun findCommonCountries(countries1: List<String>, countries2: List<String>): List<String> {

    val commonCountries = mutableListOf<String>()

    // Using a for loop to iterate over countries in the first list
    for (country in countries1) {
        // Checking if the country is present in the second list
        if (country in countries2) {
            commonCountries.add(country)
        }
    }

    return commonCountries
}