Skip to content

Instantly share code, notes, and snippets.

@xeonqq
Created September 1, 2015 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xeonqq/e995a776b4d6691612fd to your computer and use it in GitHub Desktop.
Save xeonqq/e995a776b4d6691612fd to your computer and use it in GitHub Desktop.
Codility MaxNonoverlappingSegments: Find a maximal set of non-overlapping segments.
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