Created
September 1, 2015 13:52
-
-
Save xeonqq/e995a776b4d6691612fd to your computer and use it in GitHub Desktop.
Codility MaxNonoverlappingSegments: Find a maximal set of non-overlapping segments.
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 solution(A, B): | |
# write your code in Python 2.7 | |
pre = -1 | |
N = len(A) | |
ans=0 | |
for i in xrange(N): | |
if A[i] > pre: | |
ans+=1 | |
pre = B[i] | |
return ans |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment