Pages tagged subsequence:

Longest common subsequence
http://wordaligned.org/articles/longest-common-subsequence

Starting with a list of runners ordered by finishing time, select a sublist of runners who are getting younger. What is the longest such sublist?
Longest common subsequence
Taking a brief step back, this article is the third of a series. In the first episode we posed a puzzle: Starting with a list of runners ordered by finishing time, select a sublist of runners who are getting younger. What is the longest such sublist? In the second episode we coded up a brute force solution which searched all possible sublists to find an optimal solution. Although the code was simple and succinct, its exponential complexity made it unsuitable for practical use. In this episode we’ll discuss an elegant algorithm which solves our particular problem as a special case. On the way we’ll visit dynamic programming, Python decorators, version control and genetics.