BackmediumArrays arrays medium

Book Availability Checker Solution

Problem Statement

Given an array of book objects, where each object contains a unique book identifier `bookId` and a boolean indicating its availability `isAvailable`, implement a function to check if a book exists and its availability. The function should return a boolean array where the first element indicates the existence of the book and the second element indicates its availability.

Example 1
Input
{"books":[{"bookId":1,"isAvailable":true},{"bookId":2,"isAvailable":false},{"bookId":3,"isAvailable":true}],"targetBookId":2}
Output
[true,false]

Explanation: Book with id 2 exists and is not available

Constraints

  • command cannot be empty
  • command is either find or add
  • book_title should not exceed 100 characters
  • author should not exceed 50 characters
  • input line should end with a newline character
  • member_name should not exceed 20 characters
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free