/**
 * Given two zoos represented as sets of species, find the set of species that are common to both zoos.
 *
 * @param zoo1 Set of species in the first zoo.
 * @param zoo2 Set of species in the second zoo.
 * @return Set of species common to both zoos.
 *
 * Example:
 * val zoo1 = setOf("Lion", "Elephant", "Giraffe", "Tiger")
 * val zoo2 = setOf("Elephant", "Giraffe", "Monkey", "Rhino")
 * findCommonSpecies(zoo1, zoo2) // Output: setOf("Elephant", "Giraffe")
 */
fun findCommonSpecies(zoo1: Set<String>, zoo2: Set<String>): Set<String> {

    val commonSpecies = mutableSetOf<String>() // Create a mutable set to store the common species

    // Iterate through each species in zoo1
    for (species in zoo1) {
        // Check if the species is present in zoo2
        if (species in zoo2) {
            commonSpecies.add(species) // Add the species to the common set
        }
    }

    return commonSpecies
}
/**
 * Given two zoos represented as sets of species, find the set of species that are common to both zoos.
 *
 * @param zoo1 Set of species in the first zoo.
 * @param zoo2 Set of species in the second zoo.
 * @return Set of species common to both zoos.
 *
 * Example:
 * val zoo1 = setOf("Lion", "Elephant", "Giraffe", "Tiger")
 * val zoo2 = setOf("Elephant", "Giraffe", "Monkey", "Rhino")
 * findCommonSpecies(zoo1, zoo2) // Output: setOf("Elephant", "Giraffe")
 */
fun findCommonSpecies(zoo1: Set<String>, zoo2: Set<String>): Set<String> {
/**
 * Given two zoos represented as sets of species, find the set of species that are common to both zoos.
 *
 * @param zoo1 Set of species in the first zoo.
 * @param zoo2 Set of species in the second zoo.
 * @return Set of species common to both zoos.
 *
 * Example:
 * val zoo1 = setOf("Lion", "Elephant", "Giraffe", "Tiger")
 * val zoo2 = setOf("Elephant", "Giraffe", "Monkey", "Rhino")
 * findCommonSpecies(zoo1, zoo2) // Output: setOf("Elephant", "Giraffe")
 */
fun findCommonSpecies(zoo1: Set<String>, zoo2: Set<String>): Set<String> {

    val commonSpecies = mutableSetOf<String>() // Create a mutable set to store the common species

    // Iterate through each species in zoo1
    for (species in zoo1) {
        // Check if the species is present in zoo2
        if (species in zoo2) {
            commonSpecies.add(species) // Add the species to the common set
        }
    }

    return commonSpecies
}