Filling Bookcase Shelves
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You must place books on a bookcase in the given order. Book i has thickness books[i][0] and height books[i][1]. Each shelf holds a contiguous run of the remaining books whose total thickness is at most shelfWidth, and a shelf is as tall as its tallest book.
Shelves are stacked, so the bookcase's total height is the sum of its shelf heights. Books must keep their original order (you fill one shelf, then start the next). Return the minimum possible total height.
Examples
Constraints
- `1 <= books.length <= 1000`
- `1 <= books[i][0] <= shelfWidth <= 1000`
- `1 <= books[i][1] <= 1000`
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.