-
Notifications
You must be signed in to change notification settings - Fork 19.9k
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
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. |
There was a problem hiding this 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 ParameterizedTest
s.
sure @vil02 , removed the main function and added tests! |
src/main/java/com/thealgorithms/dynamicprogramming/LongestArithmeticSubsequence.java
Outdated
Show resolved
Hide resolved
src/main/java/com/thealgorithms/dynamicprogramming/LongestArithmeticSubsequence.java
Outdated
Show resolved
Hide resolved
src/main/java/com/thealgorithms/dynamicprogramming/LongestArithmeticSubsequence.java
Outdated
Show resolved
Hide resolved
src/test/java/com/thealgorithms/dynamicprogramming/LongestArithmeticSubsequenceTest.java
Show resolved
Hide resolved
src/test/java/com/thealgorithms/dynamicprogramming/LongestArithmeticSubsequenceTest.java
Show resolved
Hide resolved
src/main/java/com/thealgorithms/dynamicprogramming/LongestArithmeticSubsequence.java
Outdated
Show resolved
Hide resolved
src/main/java/com/thealgorithms/dynamicprogramming/LongestArithmeticSubsequence.java
Outdated
Show resolved
Hide resolved
…hmeticSubsequence.java Co-authored-by: Piotr Idzik <[email protected]>
…hmeticSubsequence.java Co-authored-by: Piotr Idzik <[email protected]>
src/main/java/com/thealgorithms/dynamicprogramming/LongestArithmeticSubsequence.java
Outdated
Show resolved
Hide resolved
src/main/java/com/thealgorithms/dynamicprogramming/LongestArithmeticSubsequence.java
Outdated
Show resolved
Hide resolved
src/test/java/com/thealgorithms/dynamicprogramming/LongestArithmeticSubsequenceTest.java
Outdated
Show resolved
Hide resolved
src/main/java/com/thealgorithms/dynamicprogramming/LongestArithmeticSubsequence.java
Outdated
Show resolved
Hide resolved
src/test/java/com/thealgorithms/dynamicprogramming/LongestArithmeticSubsequenceTest.java
Outdated
Show resolved
Hide resolved
…hmeticSubsequence.java Co-authored-by: Piotr Idzik <[email protected]>
…hmeticSubsequence.java Co-authored-by: Piotr Idzik <[email protected]>
…hmeticSubsequenceTest.java Co-authored-by: Piotr Idzik <[email protected]>
…hmeticSubsequence.java Co-authored-by: Piotr Idzik <[email protected]>
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