Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int maxSubArray(vector<int>& nums) {
- int maxEnd = nums[0];
- int ext = maxEnd;
- for(int i = 1; i < nums.size(); i++) {
- maxEnd = nums[i] > nums[i] + maxEnd ? nums[i] : nums[i] + maxEnd;
- ext = ext > maxEnd ? ext : maxEnd;
- }
- return ext;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement