Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add longest alternating subsequence #624

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

FamALouiz
Copy link

References to issue

Resolves #317

Brief description of what was implemented

  • Added longest alternating subsequence
  • Added longest alternating subsequence tests

Comments

The algorithm works in O(n) using a dp + greedy solution. It does not return the actualy subsequence; instead, it returns only the length.

decreasing = increasing + 1

# Return the maximum length
return max(increasing, decreasing)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to return the increasing sequence as well and not just the length.

@FamALouiz FamALouiz requested a review from czgdp1807 March 11, 2025 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Longest Alternating Subsequence
2 participants