ELI5: Explain Like I'm 5

Longest alternating subsequence

Okay kiddo, so let's say you have a lot of numbers written down like 1, 2, 3, 4, 5, 6... and so on. Now imagine you want to find the longest pattern of alternating numbers.

What is an alternating pattern, you ask? Well, it means that the numbers should go up and down repeatedly. For example, 2 then 1 then 3 then 2 then 4 then 3 then 5 and so on...

Now, let's say you have a sequence of numbers: 1, 3, 2, 4, 3, 5, 8, 6, 9, 7, 10

Can you see an alternating pattern here? Yes, it's 1, 3, 2, 4, 3, 5, 6, 7, 10 (up, down, up, down, up, down, up, up, up). This is the longest alternating subsequence in this list because it has the most alternating numbers in a row compared to any other pattern.

So, finding the longest alternating subsequence is just finding the pattern that has the most up and down sequence of numbers. It can be tricky if the list is very long, but if you take your time and look closely, you'll find the best alternating pattern!