Skip to content

Instantly share code, notes, and snippets.

@Kishy-nivas
Created April 20, 2018 13:30
Show Gist options
  • Save Kishy-nivas/1d655325ae7e7741459ee253ebd83ccb to your computer and use it in GitHub Desktop.
Save Kishy-nivas/1d655325ae7e7741459ee253ebd83ccb to your computer and use it in GitHub Desktop.
public int continousOnes(int[] arr) {
int count =0;
int max = 0;
for(int i : arr){
if(i==1){
count++;
}
else {
max = Math.max(count,max);
count =0;
}
}
max = Math.max(count,max);
return max;
}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment