int low = *max_element(nums.begin(),nums.end()); // 8 int high = accumulate(nums.begin(),nums.end(),0); // 23 int ans = low; while(lowm) low = mid+1; else { ans = mid; //minimize ans high = mid-1; } } return ans; } int no_of_subarrays_with_max_sum_as_mid(vector&nums, int mid) { int sum =0; int count = 1; for(int i=0;imid) { sum = nums[i]; count++; } else sum+=nums[i]; } return count; }
thanks a lot.. i have watch many video. in every other video some how they get complicated in explaining how to select the low value... here its really cleared a lot...
Can you tell me the error, not getting proper output int isPossible(long long int a[], long long int n, long long int k, long long int mid) { int arrayCount = 1; long long int sum = 0; for(int i = 0; i < n; i++) { if(sum + a[i]