jeudi 27 mai 2010

Find the longest upsequence in a string


def longuest_upsequence(s):
lg_start_index = 0
lg_size = 1
current_size = 0
current_index = 0
for i in range (0 , len(s) - 1):
if s[i] < s[i+1]:
if current_size > lg_size:
lg_start_index = current_index
lg_size = current_size
curent_index = i
current_size = 1
else:
current_size++

Aucun commentaire:

Enregistrer un commentaire