Max Book Copies
Problem Overview
- Given a stream of book inventory updates by ID (positive adds a copy, negative removes one), return after each update the maximum copies held by any single book.
- Input: int array portalUpdate[n] with non-zero values; Output: int[n] where each entry is the max copies after that step.
- Constraints: 1 ≤ n ≤ 1e6; values in [-1e9, 1e9]; removals only when a copy exists.
- Context: Tracks Amazon bookseller portal inventory changes.
- Source: Amazon interviews; a coding interview problem and common interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
