class Solution { public: int maxsumofSubarray(vector<int>& arr) { int maxsum = arr[0]; for (int i = 1; i < arr.size(); ++i) { arr[i] = max(arr[i], arr[i] + arr[i - 1]); maxsum = max(maxsum, arr[i]); } return maxsum; } };