/**
 * You are a zoologist studying different species in various habitats.
 * You have been given a list of species and a list of habitats, where each habitat is represented as a list of species within it.
 * Your task is to count the number of occurrences of each species in all the habitats.
 * You need to write a function that takes in the species list and the habitats list, and returns a dictionary with species as keys and the count as values.
 *
 * @param species A list of strings representing different species.
 * @param habitats A list of lists, where each inner list represents the species in a habitat.
 * @return A dictionary with species as keys and the count as values.
 */
fun countSpeciesInHabitat(species: List<String>, habitats: List<List<String>>): Map<String, Int> {

    val countDict = mutableMapOf<String, Int>()

    for (habitat in habitats) {
        for (s in habitat) {
            countDict[s] = countDict.getOrDefault(s, 0) + 1
        }
    }

    return countDict
}
/**
 * You are a zoologist studying different species in various habitats.
 * You have been given a list of species and a list of habitats, where each habitat is represented as a list of species within it.
 * Your task is to count the number of occurrences of each species in all the habitats.
 * You need to write a function that takes in the species list and the habitats list, and returns a dictionary with species as keys and the count as values.
 *
 * @param species A list of strings representing different species.
 * @param habitats A list of lists, where each inner list represents the species in a habitat.
 * @return A dictionary with species as keys and the count as values.
 */
fun countSpeciesInHabitat(species: List<String>, habitats: List<List<String>>): Map<String, Int> {
/**
 * You are a zoologist studying different species in various habitats.
 * You have been given a list of species and a list of habitats, where each habitat is represented as a list of species within it.
 * Your task is to count the number of occurrences of each species in all the habitats.
 * You need to write a function that takes in the species list and the habitats list, and returns a dictionary with species as keys and the count as values.
 *
 * @param species A list of strings representing different species.
 * @param habitats A list of lists, where each inner list represents the species in a habitat.
 * @return A dictionary with species as keys and the count as values.
 */
fun countSpeciesInHabitat(species: List<String>, habitats: List<List<String>>): Map<String, Int> {

    val countDict = mutableMapOf<String, Int>()

    for (habitat in habitats) {
        for (s in habitat) {
            countDict[s] = countDict.getOrDefault(s, 0) + 1
        }
    }

    return countDict
}