Skip to content

Adds Longest Arithmetic Subsequence Implementation #5501

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

Merged
merged 31 commits into from
Oct 3, 2024

Conversation

tejaswi0910
Copy link
Contributor

@tejaswi0910 tejaswi0910 commented Oct 1, 2024

Description
This PR implements the Longest Arithmetic Subsequence algorithm. The algorithm identifies the length of the longest arithmetic subsequence from a given array of integers, where a subsequence is defined as arithmetic if the differences between consecutive elements are the same.

Key Changes:
Added LongestArithmeticSubsequence.java under the dynamicprogramming directory.
The implementation uses dynamic programming with a HashMap to store the differences between elements and keep track of subsequences efficiently.

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

@codecov-commenter
Copy link

codecov-commenter commented Oct 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 52.98%. Comparing base (48a2980) to head (cc9421f).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5501      +/-   ##
============================================
+ Coverage     52.93%   52.98%   +0.05%     
- Complexity     3306     3311       +5     
============================================
  Files           528      529       +1     
  Lines         15330    15343      +13     
  Branches       2922     2925       +3     
============================================
+ Hits           8115     8130      +15     
+ Misses         6881     6880       -1     
+ Partials        334      333       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tejaswi0910 tejaswi0910 marked this pull request as ready for review October 1, 2024 14:06
Copy link
Member

@vil02 vil02 left a comment

Choose a reason for hiding this comment

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

Please remove the main method and add proper junit tests instead. Prefer ParameterizedTests.

@tejaswi0910
Copy link
Contributor Author

Please remove the main method and add proper junit tests instead. Prefer ParameterizedTests.

sure @vil02 , removed the main function and added tests!

@vil02 vil02 self-assigned this Oct 2, 2024
@vil02 vil02 merged commit be8df21 into TheAlgorithms:master Oct 3, 2024
6 checks passed
@vil02
Copy link
Member

vil02 commented Oct 3, 2024

Just a small tip: if you want to modify the last commit, you can use git commit --amend and then just push your changes with --force.

Happy hacktoberfest!

@tejaswi0910
Copy link
Contributor Author

Just a small tip: if you want to modify the last commit, you can use git commit --amend and then just push your changes with --force.

Happy hacktoberfest!

Thanks @vil02, didn't know this....will surely use this in the future!

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.

3 participants