Created
December 1, 2014 17:52
-
-
Save kvalv/c2db6c2c03bb6637b760 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def longestSeq(array): | |
| longestLen = 0 | |
| longestLenIndex = 0 | |
| currentLen = 0 | |
| currentIndex = 0 | |
| for i in range(len(array)): | |
| if array[i] == 1 and array[i-1] == 0 or i == 0: | |
| currentIndex = i | |
| if array[i] == 1: | |
| currentLen += 1 | |
| if longestLen < currentLen: | |
| longestLen = currentLen | |
| longestLenIndex = currentIndex | |
| if array[i] != 1: | |
| currentLen = 0 | |
| return longestLenIndex |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment