All Problems
Problem #75 MEDIUM

The Locked Library

Meta Apple Combinatorics Permutations

Problem Statement

A library has 7 identical-looking books in a row on a shelf. A librarian scrambles them into a random order. You are given the task of sorting them back into the correct order (book 1 on the left through book 7 on the right) using only a sequence of swaps — each swap exchanges the positions of any two books. What is the minimum number of swaps needed in the worst case? What is the average number of swaps needed over all possible random arrangements?

Answer & Quick Explanation

Logged-in Users Only

You must be logged in to view the answer and check your solution. Signing up is free and takes less than a minute.

Detailed Editorial Solution

Detailed Editorial Solution is Premium

Unlock detailed step-by-step mathematical proofs, logic explanations, and company-specific interview preparation pathways.