Horje
print maximum sum subarray Code Example
print maximum sum subarray
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int  i = 0;i<n;i++){
		cin>>a[i];
	}
	int s = 0;
	int mx = INT_MIN;
	for(int  i =0;i<n;i++){
		s+=a[i];
		if(s<0){
			s=0;
		}
		mx = max(s,mx);
	}
	cout<<mx;
	return 0;
}




Cpp

Related
Check whether K-th bit is set or not c++ Code Example Check whether K-th bit is set or not c++ Code Example
extra parameter in comparator function for sort Code Example extra parameter in comparator function for sort Code Example
is power of 2 Code Example is power of 2 Code Example
executing linux scripts Code Example executing linux scripts Code Example
what is handling null terminated string in c++ Code Example what is handling null terminated string in c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8