/**
 * Given a list of books to remove, remove them from the library system.
 *
 * @param library A list representing the library system with books.
 * @param booksToRemove A list of books to be removed from the library system.
 * @return The updated library system with books removed.
 *
 * Example:
 * '``
 * val library = mutableListOf("Book1", "Book2", "Book3", "Book4")
 * val booksToRemove = listOf("Book2", "Book3")
 * removeBooks(library, booksToRemove)
 * // Output: [Book1, Book4]
 * '``
 */
fun removeBooks(library: MutableList<String>, booksToRemove: List<String>): List<String> {

    val newLibrary = ArrayList(library) // Create a new copy of the library system

    // Iterate over each book in the list of books to remove
    for (book in booksToRemove) {
        // Check if the book exists in the library system
        if (book in library) {
            // Find the index of the book in the library system
            val index = library.indexOf(book)
            newLibrary.removeAt(index) // Remove the book from the new library
        }
    }

    return newLibrary
}
/**
 * Given a list of books to remove, remove them from the library system.
 *
 * @param library A list representing the library system with books.
 * @param booksToRemove A list of books to be removed from the library system.
 * @return The updated library system with books removed.
 *
 * Example:
 * '``
 * val library = mutableListOf("Book1", "Book2", "Book3", "Book4")
 * val booksToRemove = listOf("Book2", "Book3")
 * removeBooks(library, booksToRemove)
 * // Output: [Book1, Book4]
 * '``
 */
fun removeBooks(library: MutableList<String>, booksToRemove: List<String>): List<String> {
/**
 * Given a list of books to remove, remove them from the library system.
 *
 * @param library A list representing the library system with books.
 * @param booksToRemove A list of books to be removed from the library system.
 * @return The updated library system with books removed.
 *
 * Example:
 * '``
 * val library = mutableListOf("Book1", "Book2", "Book3", "Book4")
 * val booksToRemove = listOf("Book2", "Book3")
 * removeBooks(library, booksToRemove)
 * // Output: [Book1, Book4]
 * '``
 */
fun removeBooks(library: MutableList<String>, booksToRemove: List<String>): List<String> {

    val newLibrary = ArrayList(library) // Create a new copy of the library system

    // Iterate over each book in the list of books to remove
    for (book in booksToRemove) {
        // Check if the book exists in the library system
        if (book in library) {
            // Find the index of the book in the library system
            val index = library.indexOf(book)
            newLibrary.removeAt(index) // Remove the book from the new library
        }
    }

    return newLibrary
}