/**
 * This function checks whether a book is returned on time or is overdue.
 *
 * @param returnedBooks A list of book titles that have been returned
 * @param overdueBooks A list of book titles that are overdue
 * @return True if the book is returned on time, False if it is overdue
 */
fun checkBookReturnDate(returnedBooks: List<String>, overdueBooks: List<String>): Boolean {

    return when {
        returnedBooks.isNotEmpty() && overdueBooks.isNotEmpty() -> {
            // Check if the returned book is also considered as overdue
            if (returnedBooks.last() in overdueBooks) {
                false
            } else {
                true
            }
        }
        returnedBooks.isNotEmpty() -> {
            // If the book is returned but not in the overdue books list, it is considered on time
            true
        }
        else -> false
    }
}

val bookList = listOf("Book 1", "Book 2", "Book 3", "Book 4")
val returnedBooks = listOf("Book 2", "Book 4")
val overdueBooks = listOf("Book 3")

// Check if the first book in the list is returned on time or is overdue
val isReturnedOnTime = checkBookReturnDate(returnedBooks, overdueBooks)
/**
 * This function checks whether a book is returned on time or is overdue.
 *
 * @param returnedBooks A list of book titles that have been returned
 * @param overdueBooks A list of book titles that are overdue
 * @return True if the book is returned on time, False if it is overdue
 */
fun checkBookReturnDate(returnedBooks: List<String>, overdueBooks: List<String>): Boolean {
/**
 * This function checks whether a book is returned on time or is overdue.
 *
 * @param returnedBooks A list of book titles that have been returned
 * @param overdueBooks A list of book titles that are overdue
 * @return True if the book is returned on time, False if it is overdue
 */
fun checkBookReturnDate(returnedBooks: List<String>, overdueBooks: List<String>): Boolean {

    return when {
        returnedBooks.isNotEmpty() && overdueBooks.isNotEmpty() -> {
            // Check if the returned book is also considered as overdue
            if (returnedBooks.last() in overdueBooks) {
                false
            } else {
                true
            }
        }
        returnedBooks.isNotEmpty() -> {
            // If the book is returned but not in the overdue books list, it is considered on time
            true
        }
        else -> false
    }
}

val bookList = listOf("Book 1", "Book 2", "Book 3", "Book 4")
val returnedBooks = listOf("Book 2", "Book 4")
val overdueBooks = listOf("Book 3")

// Check if the first book in the list is returned on time or is overdue
val isReturnedOnTime = checkBookReturnDate(returnedBooks, overdueBooks)