/**
 * A zoologist wants to find the common species present in two different zoos.
 * Given two lists 'zoo1' and 'zoo2' containing the species names as strings, find the common species.
 *
 * @param zoo1 A list of species present in the first zoo
 * @param zoo2 A list of species present in the second zoo
 * @return A list of common species in alphabetical order
 *
 * Example:
 * findCommonSpecies(listOf("lion", "elephant", "giraffe", "tiger"), listOf("giraffe", "lion", "tiger", "monkey"))
 * Output: ['giraffe', 'lion', 'tiger']
 */
fun findCommonSpecies(zoo1: List<String>, zoo2: List<String>): List<String> {

    val commonSpecies = mutableListOf<String>()

    for (species in zoo1) {
        if (species in zoo2 && species !in commonSpecies) {
            commonSpecies.add(species)
        }
    }

    return commonSpecies.sorted()
}
/**
 * A zoologist wants to find the common species present in two different zoos.
 * Given two lists 'zoo1' and 'zoo2' containing the species names as strings, find the common species.
 *
 * @param zoo1 A list of species present in the first zoo
 * @param zoo2 A list of species present in the second zoo
 * @return A list of common species in alphabetical order
 *
 * Example:
 * findCommonSpecies(listOf("lion", "elephant", "giraffe", "tiger"), listOf("giraffe", "lion", "tiger", "monkey"))
 * Output: ['giraffe', 'lion', 'tiger']
 */
fun findCommonSpecies(zoo1: List<String>, zoo2: List<String>): List<String> {
/**
 * A zoologist wants to find the common species present in two different zoos.
 * Given two lists 'zoo1' and 'zoo2' containing the species names as strings, find the common species.
 *
 * @param zoo1 A list of species present in the first zoo
 * @param zoo2 A list of species present in the second zoo
 * @return A list of common species in alphabetical order
 *
 * Example:
 * findCommonSpecies(listOf("lion", "elephant", "giraffe", "tiger"), listOf("giraffe", "lion", "tiger", "monkey"))
 * Output: ['giraffe', 'lion', 'tiger']
 */
fun findCommonSpecies(zoo1: List<String>, zoo2: List<String>): List<String> {

    val commonSpecies = mutableListOf<String>()

    for (species in zoo1) {
        if (species in zoo2 && species !in commonSpecies) {
            commonSpecies.add(species)
        }
    }

    return commonSpecies.sorted()
}