/**
 * This function takes in a library map and a map of new books.
 * It updates the library map by adding the new books to the appropriate collection.
 *
 * @param library A map representing the library's book collections.
 * @param newBooks A map containing the new books to be added to the library.
 *                 The keys represent the collection names and the values represent the book titles.
 * @return The updated library map with the new books added to the respective collections.
 */
fun updateBookCollections(library: MutableMap<String, MutableMap<String, Int>>, newBooks: Map<String, List<String>>): MutableMap<String, MutableMap<String, Int>> {

    for ((collection, books) in newBooks) {
        if (!library.containsKey(collection)) {
            library[collection] = mutableMapOf()
        }
        for (book in books) {
            library[collection]!![book] = (library[collection]?.get(book) ?: 0) + 1
        }
    }
    return library
}
/**
 * This function takes in a library map and a map of new books.
 * It updates the library map by adding the new books to the appropriate collection.
 *
 * @param library A map representing the library's book collections.
 * @param newBooks A map containing the new books to be added to the library.
 *                 The keys represent the collection names and the values represent the book titles.
 * @return The updated library map with the new books added to the respective collections.
 */
fun updateBookCollections(library: MutableMap<String, MutableMap<String, Int>>, newBooks: Map<String, List<String>>): MutableMap<String, MutableMap<String, Int>> {
/**
 * This function takes in a library map and a map of new books.
 * It updates the library map by adding the new books to the appropriate collection.
 *
 * @param library A map representing the library's book collections.
 * @param newBooks A map containing the new books to be added to the library.
 *                 The keys represent the collection names and the values represent the book titles.
 * @return The updated library map with the new books added to the respective collections.
 */
fun updateBookCollections(library: MutableMap<String, MutableMap<String, Int>>, newBooks: Map<String, List<String>>): MutableMap<String, MutableMap<String, Int>> {

    for ((collection, books) in newBooks) {
        if (!library.containsKey(collection)) {
            library[collection] = mutableMapOf()
        }
        for (book in books) {
            library[collection]!![book] = (library[collection]?.get(book) ?: 0) + 1
        }
    }
    return library
}