Dsa
Binary Search
Easy
Find Book
You are given an array of book titles sorted lexicographically. A title might be missing from this sorted array. Write a program to find the index of a given title. If the title is not found, return -1. The input will consist of the first line with space-separated book titles and the second line with the title to search for. Output one integer, the index of the title or -1 if not found.
Example:
Input:
A Tale of Two Cities Great Expectations Moby Dick To Kill a Mockingbird
Moby Dick
Output:
2
Key concepts
binary_searchsearch
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