From f6935c1a826d6e0f6984c0a645e73975963dc07b Mon Sep 17 00:00:00 2001 From: Manav Narang Date: Sat, 21 Dec 2024 18:15:06 +0530 Subject: [PATCH] Update bookAllocationProblem.cpp New changes to pass all the testcases. --- .../bookAllocationProblem.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lecture015 Binary Search Advanced Problems/bookAllocationProblem.cpp b/Lecture015 Binary Search Advanced Problems/bookAllocationProblem.cpp index ebedf1d1..ccc62e1b 100644 --- a/Lecture015 Binary Search Advanced Problems/bookAllocationProblem.cpp +++ b/Lecture015 Binary Search Advanced Problems/bookAllocationProblem.cpp @@ -27,6 +27,9 @@ bool isPossible(vector arr, int n, int m, int mid) { } int allocateBooks(vector arr, int n, int m) { + if(m>n){ + return -1; + } int s = 0; int sum = 0; @@ -51,4 +54,4 @@ int allocateBooks(vector arr, int n, int m) { mid = s + (e-s)/2; } return ans; -} \ No newline at end of file +}