From dec87615567d6c306c3e6ac2908c33be3b16237b Mon Sep 17 00:00:00 2001 From: Anupam Haldkar Date: Mon, 7 Feb 2022 16:43:12 +0530 Subject: [PATCH] Update Bashar and the bad land.cpp I have remove the condition when left and right are same, it doesn't matter because atleast he has to go either one house to achieve. I have successfully submitted the code in the platform as well. --- Bashar and the bad land.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Bashar and the bad land.cpp b/Bashar and the bad land.cpp index 7708e44..13f2adc 100644 --- a/Bashar and the bad land.cpp +++ b/Bashar and the bad land.cpp @@ -24,16 +24,8 @@ void solve(){ // cout << l << ' ' << r << " " << t << "\n"; if(t >= x){ b = min(b, r - l + 1); - if(l == r){ - t-=a[l]; - l++; - r++; - t+=a[r]; - } - else{ - t-=a[l]; - l++; - } + t-=a[l]; + l++; continue; } r++; @@ -57,4 +49,4 @@ int main() solve(); return 0; -} \ No newline at end of file +}