/**
 * The veterinarian is comparing the animal species from different records.
 * The task is to find the common animal species in all the records.
 *
 * @param veterinarianRecords a list of records, where each record is a Pair of (animalSpecies, recordNumber)
 * @return a list of animal species that are common in all the records
 */
fun compareAnimalSpecies(veterinarianRecords: List<Pair<List<String>, Int>>): List<String> {

    // Step 1: Initialize the commonSpeciesList with the animal species from the first record
    var commonSpeciesList = veterinarianRecords[0].first.toMutableList()

    // Step 2: Iterate over the remaining records and update the commonSpeciesList
    for (i in 1 until veterinarianRecords.size) {
        val record = veterinarianRecords[i]
        // Iterate over each animal species in the record
        val iterator = commonSpeciesList.iterator()
        while (iterator.hasNext()) {
            val species = iterator.next()
            // Check if the species is not present in the current record
            if (species !in record.first) {
                // If the species is not present, remove it from the list
                iterator.remove()
            }
        }
    }

    // Step 3: Return the final commonSpeciesList
    return commonSpeciesList
}
/**
 * The veterinarian is comparing the animal species from different records.
 * The task is to find the common animal species in all the records.
 *
 * @param veterinarianRecords a list of records, where each record is a Pair of (animalSpecies, recordNumber)
 * @return a list of animal species that are common in all the records
 */
fun compareAnimalSpecies(veterinarianRecords: List<Pair<List<String>, Int>>): List<String> {
/**
 * The veterinarian is comparing the animal species from different records.
 * The task is to find the common animal species in all the records.
 *
 * @param veterinarianRecords a list of records, where each record is a Pair of (animalSpecies, recordNumber)
 * @return a list of animal species that are common in all the records
 */
fun compareAnimalSpecies(veterinarianRecords: List<Pair<List<String>, Int>>): List<String> {

    // Step 1: Initialize the commonSpeciesList with the animal species from the first record
    var commonSpeciesList = veterinarianRecords[0].first.toMutableList()

    // Step 2: Iterate over the remaining records and update the commonSpeciesList
    for (i in 1 until veterinarianRecords.size) {
        val record = veterinarianRecords[i]
        // Iterate over each animal species in the record
        val iterator = commonSpeciesList.iterator()
        while (iterator.hasNext()) {
            val species = iterator.next()
            // Check if the species is not present in the current record
            if (species !in record.first) {
                // If the species is not present, remove it from the list
                iterator.remove()
            }
        }
    }

    // Step 3: Return the final commonSpeciesList
    return commonSpeciesList
}