Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Kadane's Algorithm
class Solution { public: int maxSubArray(vector<int>& nums) { int overall_max=nums[0]; int curr_max=nums[0]; for(int i=1;i<nums.size();i++) { curr_max=curr_max+nums[i]; if(curr_max<nums[i]) { curr_max=nums[i]; } overall_max=max(overall_max,curr_max); } return overall_max; } };
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Counting top students
Guess Number
For Hello World
LRU cache
matrix calculator
PointPattern
Text Justification
Divide
test
add all
Please log in to post a comment.