Question bank › Binary Search
Dsa Binary Search Medium

Book Page Search

A librarian wants to find the page number of a specific book title in a sorted list of book titles. If found, return the page number (index) of the title; else return -1. Input format: - The first line contains an integer n, the number of book titles. - The second line contains n sorted strings (the book titles). - The third line contains the string title to search. Output format: - Print the index of the book title or -1 if it does not exist. Example: Input: 4 A Tale of Two Cities Moby Dick Pride and Prejudice The Great Gatsby Moby Dick Output: 1

Key concepts

binary_searchbooksarrays

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.