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

Return longestIncreasingSubsequence from dpLongestIncreasingSubsequence #1164

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

shola
Copy link

@shola shola commented Aug 22, 2024

The Longest Increasing Subsequence README.md and dpLongestIncreasingSubsequence.test.js give examples of the longest increasing subsequence that will be generated from various sequences:

In the first 16 terms of the binary Van der Corput sequence

0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15

a longest increasing subsequence is

0, 2, 6, 9, 11, 15.

However, the implemented algorithm only returns the length of the longest increasing subsequence, not the subsequence itself. This change will create the longestIncreasingSubsequence from the lengthsArray and return that instead of longestIncreasingLength.

The tests have been updated to expect a subsequence instead of length.

Copy link

@jessbennett jessbennett left a comment

Choose a reason for hiding this comment

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

❇️

@shola
Copy link
Author

shola commented Sep 20, 2024

@trekhleb what do you think of this change?

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.

4 participants