title: Optimal way to read a book having N chapters in M days
body: <p>I came across this interview question: Given a book with N chapters (each chapter has of course different number of pages), what is the optimal way to complete the entire book in M days with the constraint that a chapter has to be read completely on the same day.</p>
  
  <p>Example: </p>
  
  <pre><code>Chapters[] = {7, 5, 3, 9, 10}
  Days = 4
  </code></pre>
  
  <p>One should read:</p>
  
  <p><code>Chapter1 on Day1</code>, <code>Chapters2 and Chapter3 on Day2</code>, 
  <code>Chapter4 on Day3</code> and <code>Chapter5 on Day4</code>. </p>
  
  <p>I understand that the idea should be to minimize the sum of absolute differences of total pages read with the average number of pages that one should 'ideally' read on one day. However, I am not able to translate this idea to a data structure and an algorithm. Any other idea or inputs are appreciated.</p>