Adds Longest Arithmetic Subsequence Implementation#5501
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
vil02
left a comment
There was a problem hiding this comment.
Please remove the main method and add proper junit tests instead. Prefer ParameterizedTests.
sure @vil02 , removed the main function and added tests! |
…hmeticSubsequence.java Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
…hmeticSubsequence.java Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
…hmeticSubsequence.java Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
…hmeticSubsequence.java Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
…hmeticSubsequenceTest.java Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
…hmeticSubsequence.java Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
|
Just a small tip: if you want to modify the last commit, you can use Happy hacktoberfest! |
Thanks @vil02, didn't know this....will surely use this in the future! |
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.
clang-format -i --style=file path/to/your/file.java