This is a verified interview question from Bny. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "The Library Problem" covers key patterns like Other.
"Sam has been appointed as the new Librarian in a library. He needs to perform the following operations on the N books arranged in the bookshelves to get a unique combination of books: - He must select a K-length contiguous sequence of books from the bookshelf. - He must then remove the books that were chosen. - Then he needs to merge the remaining books and determine whether the resulting sequence is unique. - He has to repeat this operation for all possible contiguous segments of books from the N books on the bookshelf. Given an array A which represents the N books in the bookshelves, your task is to help Sam find and return an integer value representing all the possible unique combinations of books that can be generated."
Join thousands of developers practicing for Bny.