Skip to content
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

Fix recursion issues in algorithms/sets/combination-sum #458

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

cascandaliato
Copy link

My changes should fix #308.

I have refactored combinationSum to use an iterative approach to avoid stack overflows when the decision tree gets too deep (candidates=[1], target=100000).

Additionally, the code now filters out any candidate equal to zero to avoid loops.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
- Refactor combinationSum to use an iterative algorithm (to avoid stack overflows).
- Ignore candidates equal to zero (to avoid loops).

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@codecov
Copy link

codecov bot commented Jan 30, 2020

Codecov Report

Merging #458 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #458   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files         149    149           
  Lines        2612   2618    +6     
  Branches      434    434           
=====================================
+ Hits         2612   2618    +6
Impacted Files Coverage Δ
.../algorithms/sets/combination-sum/combinationSum.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ba2d8dc...2f60cab. Read the comment docs.

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.

Infinite recursion in combinationSum
1 participant