Find Minimum Pages Per Day
A student is preparing for a test from amazon academy for a scholarship.
The student is required to completely read n chapters (which is the length of the pages array) for the test where the ith chapter has pages[i] number of pages. The chapters are read in increasing order of the index. Each day the student can either read till the end of a chapter or at the most x pages, whichever is minimum. The number of pages remaining to read decreases by x in the later case.
Note:
The test will be given in [days] number of days from now. Find the minimum number of the pages, x, which the student should read each day to finish all pages of all chapters within days number of days. If it is not possible to finish these chapters in days number of days, return -1.
Complete the function findMinimumPagesPerDay in the editor.
findMinimumPagesPerDay has the following parameters:
int pages[n]: an array of integers representing the number of pages in each chapterint days: the number of days to finish readingReturns
int: the minimum number of pages to read each day, or -1 if it's not possible
Note: In one day, the student cannot read pages of more than one chapter. Thus, if a chapeter finishes, the next chapter starts only on the next day even if the num of pages read is less than x.
✨ Credit to ꒰ August ꒱ؘ ࿐ ࿔*:・゚✨
1Example 1
2Example 2
3Example 3

Constraints
Limits and guarantees your solution can rely on.
1 <= n <= 10^51 <= days <= 10^91 <= pages[i] <= 10^4