MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / maxones

Function maxones

CPP/arrays/Max_Consecutive_Ones.cpp:4–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2using namespace std;
3
4int maxones(bool a[],int n){
5 int res=0,cur=0;
6 for(int i=0;i<n;i++){
7 if(a[i]==0){
8 cur=0;
9 }
10 else{
11 cur++;
12 res=max(res,cur);
13 }
14 }
15 return res;
16}
17
18int main(){
19 bool a[]={1,1,1,0,1,1,1,0,1,0,1,0,1,1};

Callers 1

mainFunction · 0.85

Calls 1

maxFunction · 0.50

Tested by

no test coverage detected