Skip to content

Conversation

@Tejasrahane
Copy link

Implements the Combination Sum algorithm using recursion and backtracking. This class finds all unique combinations of distinct integers that sum to a target value, where numbers can be used multiple times.

  • Added comprehensive JavaDoc documentation
  • Included Wikipedia and LeetCode references
  • Follows project naming conventions
  • Uses proper recursion and backtracking techniques

Fixes #6804

  • 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

Implements the Combination Sum algorithm using recursion and backtracking. This class finds all unique combinations of distinct integers that sum to a target value, where numbers can be used multiple times.

- Added comprehensive JavaDoc documentation
- Included Wikipedia and LeetCode references
- Follows project naming conventions
- Uses proper recursion and backtracking techniques

Fixes TheAlgorithms#6804
@codecov-commenter
Copy link

codecov-commenter commented Oct 21, 2025

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.01%. Comparing base (873dd97) to head (59d8beb).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...va/com/thealgorithms/recursion/CombinationSum.java 93.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6869      +/-   ##
============================================
+ Coverage     77.96%   78.01%   +0.04%     
- Complexity     6431     6450      +19     
============================================
  Files           736      738       +2     
  Lines         21476    21534      +58     
  Branches       4204     4211       +7     
============================================
+ Hits          16744    16799      +55     
- Misses         4060     4062       +2     
- Partials        672      673       +1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DenizAltunkapan
Copy link
Member

@Tejasrahane Please add a corresponding test class so i can start the review

@Tejasrahane
Copy link
Author

Thank you for the review @DenizAltunkapan! I will add a corresponding test class for the CombinationSum algorithm to ensure proper test coverage.

Could you please confirm if there are any specific test cases or edge cases you would like me to include in the test class? I want to make sure the tests meet the project's standards for the review process.

I'll update the PR with the test class shortly.

This test class covers various scenarios for the CombinationSum algorithm, including edge cases and multiple combinations.
Removed all instances of 'new CombinationSum()' in testBasicCase, testMultipleCombinations, and testNoSolution methods. Updated all calls to use the static method CombinationSum.combinationSum() directly instead of creating an instance, as the CombinationSum class has a private constructor and is designed to be used statically.
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.

[FEATURE REQUEST] Add Combination Sum algorithm using recursion (java) (hacktoberfest'25)

3 participants