Skip to content

added longest sequence array #561

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Anuragcr07
Copy link

Because

This PR adds a new JavaScript exercise that challenges students to find the longest consecutive sequence in an unsorted array. It reinforces important concepts like array iteration, use of Sets for efficient lookup, and performance optimization beyond brute-force solutions.

This PR

  • Added a new exercise file: longestSequence.js containing the function longestConsecutive()
  • Created a test file: longestSequence.spec.js using Jest to validate multiple input cases
  • Included logic in tests to print both the length and the actual longest sequence for clarity
  • Ensured edge cases such as empty arrays and disjoint inputs are tested

Issue

Closes #530

Additional Information

This challenge helps learners strengthen their understanding of array-based problem-solving and introduces performance-oriented thinking by avoiding brute force and leveraging Sets.

Pull Request Requirements

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this PR follows the location of change: brief description of change format, e.g. 17_longestSequence: Add longest consecutive sequence exercise
  • The Because section summarizes the reason for this PR
  • The This PR section has a bullet point list describing the changes in this PR
  • If this PR addresses an open issue, it is linked in the Issue section
  • If this PR includes any changes that affect the solution of an exercise, I've also updated the solution in the /solutions folder

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.

Proposal: Add New Exercise – "Find the Longest Consecutive Sequence"
1 participant