-
Notifications
You must be signed in to change notification settings - Fork 18.9k
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
Refactor: Combination #5225
Refactor: Combination #5225
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5225 +/- ##
============================================
- Coverage 40.35% 40.32% -0.04%
+ Complexity 2486 2484 -2
============================================
Files 519 519
Lines 15479 15474 -5
Branches 2950 2949 -1
============================================
- Hits 6247 6240 -7
- Misses 8943 8944 +1
- Partials 289 290 +1 ☔ View full report in Codecov by Sentry. |
src/test/java/com/thealgorithms/backtracking/CombinationTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/thealgorithms/backtracking/CombinationTest.java
Outdated
Show resolved
Hide resolved
} else if (combinationSize == 0) { | ||
return null; | ||
} |
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.
I do not see a reason to return null
here. You can just remove this branch, so the result would be Arrays.asList(new TreeSet<Integer>())
.
The problem is I force merged #5181, so this ArrayCombination
. The method combination
will need an update.null
problem will no longer occur.
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.
Could you please:
- add a test case with
data
being an empty array andcombinationSize
being positive, - add a test case with
data
being an empty array andcombinationSize
being zero, - add a test case with
data
being[1, 2, 3]
andcombinationSize
being2
, - add a test case with data being an array of strings.
import java.util.List; | ||
import java.util.TreeSet; | ||
|
||
/** | ||
* Finds all permutations of given array | ||
* @author Alan Piao (<a href="https://github.com/cpiao3">git-Alan Piao</a>) | ||
* Finds all combinations of a given array of unique elements. |
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.
This is not verified anywhere. Maybe the input type should be Set<T>
? Or maybe this statement is not needed. I think what we are aiming for it to mimic the itertools.combinations
from python.
Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution! |
Please reopen this pull request once you have made the required changes. If you need help, feel free to ask in our Discord server or ping one of the maintainers here. Thank you for your contribution! |
Related to #5164
clang-format -i --style=file path/to/your/file.java