• + 0 comments

    Java Easy Solution:

    1. Iterate Each Chapter with new page.
    2. result++ when pages matches the chapter problem index
    3. Take care of each chapter page incement max k
    public static int workbook(int n, int k, List<Integer> arr) {
            int pages = 0;
            int result = 0;
            for (int chapter : arr) {
                pages++;
                for (int i = 1; i <= chapter; i++) {
                    if (pages == i) {
                        result++;
                    }
                    if (i % k == 0 && i < chapter) {
                        pages++;
                    }
                }
            }
            return result;
        }