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
from

Conversation

@casca
Copy link

casca commented Jan 30, 2020

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.

casca added 3 commits Jan 30, 2020
- Refactor combinationSum to use an iterative algorithm (to avoid stack overflows).
- Ignore candidates equal to zero (to avoid loops).
@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.

@casca casca requested a review from trekhleb Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

1 participant
You can’t perform that action at this time.