category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

Largest Sum Subarray of Size at least K

Implementation ```cpp using ll = long long int; ll maxSumWithK(ll arr[], ll n, ll k) { using ll = long long int; vector max_sum(n, 0); max_sum[0] = arr[0]; ll curr_max = arr[0]; for (int i = 1; i < n; i++) { curr_max = max(arr[i], curr_max + arr[i]); max_sum[i] = curr_max; } ll sum = 0; for (int i = 0; i < k; i++) { sum += arr[i]; } ll ans = sum; for (int i = k; i < n; i++) { sum += arr[i] - arr[i - k]; ans = max({ans, sum + max_sum[i - k], sum}); } return ans; } ``` </details>