This is a verified interview question from Squarepoint-capital. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Minimum Operations to Remove Encyclopedias - Squarepoint Capital" covers key patterns like Arrays.
"Cole volunteers as a shelver at the school library, where the encyclopedias need to be re-organized. After re-organizing all the encyclopedias, Cole realizes that some of the encyclopedias are shelved in the wrong order. To fix the mistake, Cole decides to remove all the encyclopedias from the $n$ by $m$ shelf. While reshelving the encyclopedias, Cole realizes that the most efficient way to reshelve the encyclopedias is to select one encyclopedia, remove it, and remove all the other encyclopedias in the same row and column that the author wrote of the encyclopedia Cole chose. Cole wants to determine the minimum number of encyclopedias that need to be selected to remove all the encyclopedias from the shelf. ### Input - $n$ and $m$: dimensions of the shelf - $bookshelf$: an $n \times m$ matrix representing the encyclopedias on the shelf, where $bookshelf[i][j]$ represents the author of the encyclopedia at position $(i, j)$ - $k$: the number of authors ### Output The minimum number of operations required to remove all encyclopedias. ### Constraints - $1 \leq n, m \leq 1000$ - $1 \leq k \leq 1000$ - $1 \leq bookshelf[i][j] \leq k$"
Join thousands of developers practicing for Squarepoint-capital.