/**
 * This function takes vetData map and petData list as input and returns the set of common pets
 * that the veterinarian treats and that are present in the petData list.
 *
 * @param vetData A map containing the veterinarian's pet data.
 * @param petData A list containing pet names.
 * @return A set of common pets that are treated by the veterinarian and are present in the petData list.
 *
 * Example:
 * vetData = mapOf("Cats" to listOf("Milo", "Luna"), "Dogs" to listOf("Max", "Charlie"))
 * petData = listOf("Luna", "Bella", "Max")
 * findCommonPets(vetData, petData) // Output: setOf("Luna", "Max")
 */
fun findCommonPets(vetData: Map<String, List<String>>, petData: List<String>): Set<String> {

    val commonPets = mutableSetOf<String>()

    for ((petType, pets) in vetData) {
        if (petType in petData) {
            commonPets.addAll(pets)
        }
    }

    return commonPets
}
/**
 * This function takes vetData map and petData list as input and returns the set of common pets
 * that the veterinarian treats and that are present in the petData list.
 *
 * @param vetData A map containing the veterinarian's pet data.
 * @param petData A list containing pet names.
 * @return A set of common pets that are treated by the veterinarian and are present in the petData list.
 *
 * Example:
 * vetData = mapOf("Cats" to listOf("Milo", "Luna"), "Dogs" to listOf("Max", "Charlie"))
 * petData = listOf("Luna", "Bella", "Max")
 * findCommonPets(vetData, petData) // Output: setOf("Luna", "Max")
 */
fun findCommonPets(vetData: Map<String, List<String>>, petData: List<String>): Set<String> {
/**
 * This function takes vetData map and petData list as input and returns the set of common pets
 * that the veterinarian treats and that are present in the petData list.
 *
 * @param vetData A map containing the veterinarian's pet data.
 * @param petData A list containing pet names.
 * @return A set of common pets that are treated by the veterinarian and are present in the petData list.
 *
 * Example:
 * vetData = mapOf("Cats" to listOf("Milo", "Luna"), "Dogs" to listOf("Max", "Charlie"))
 * petData = listOf("Luna", "Bella", "Max")
 * findCommonPets(vetData, petData) // Output: setOf("Luna", "Max")
 */
fun findCommonPets(vetData: Map<String, List<String>>, petData: List<String>): Set<String> {

    val commonPets = mutableSetOf<String>()

    for ((petType, pets) in vetData) {
        if (petType in petData) {
            commonPets.addAll(pets)
        }
    }

    return commonPets
}