Company: Google
Difficulty: medium
The Grand Archive has discovered N ancient scroll fragments laid out in a row, each carrying a restoration difficulty rating. A team of R expert restorers is brought in to handle all fragments. Every restorer must be assigned a contiguous block of fragments, and no fragment can go unassigned. A restorer's strain is calculated as the sum of difficulty ratings in their block multiplied by the number of distinct difficulty values present in that block — the more varied the work, the harder the mental load. To protect the wellbeing of the restorers, the archive wants to assign blocks such that the maximum strain across all restorers is minimized. Find the optimal assignment to keep the most burdened restorer as stress-free as possible. Function Description Implement the function scrollRestoration that partitions N scroll fragments into at most R contiguous blocks and returns the minimized maximum strain across all restorers. Parameters: N ( int ): Total number of scroll fragments. R ( int