A print view must split a long feed into exactly pages pages. heights[i] is the height of post i in pixels. Posts stay in order, each page holds one or more posts next to each other, and a post can't be split across pages.
The tallest page decides how much the layout needs to scale, so it should be as short as possible. Write minTallestPage(heights, pages) that returns the smallest possible height of the tallest page.
Input: heights = [7,2,5,10,8], pages = 2 Output: 18
Split as [7, 2, 5] and [10, 8]: the pages are 14 and 18 tall. No split does better.
Input: heights = [1,2,3,4,5], pages = 2 Output: 9
[1, 2, 3] and [4, 5] give pages of 6 and 9.
1 <= pages <= heights.length <= 100000 <= heights[i] <= 10^6Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #171 Split a Feed Into Pages. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.