Created
April 20, 2018 13:30
-
-
Save Kishy-nivas/1d655325ae7e7741459ee253ebd83ccb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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