You are viewing a single comment's thread. Return to all comments →
My code in JAVA 8
public static int workbook(int noOfChapters, int k, List<Integer> arr) { int pageNo = 0, result = 0; for (int i = 0; i < noOfChapters; i++) { // 0 1 2 3 4 int j = 1; while (j <= arr.get(i)) { // 1 2 3 4 int start = j; // 4 int end = arr.get(i) > start+k-1 ? start+k-1 : arr.get(i); // 4 > 6 j = end + 1; // 4 pageNo++; System.out.println(pageNo + " " + start + " " + end); if (pageNo>=start && pageNo<=end) result++; } } System.out.println(result); return result; }
Seems like cookies are disabled on this browser, please enable them to open this website
Lisa's Workbook
You are viewing a single comment's thread. Return to all comments →
My code in JAVA 8