London | 26-SDC-March | Jamal Laqdiem| Sprint 2 | Improve code with caches - #214
Open
jamallaqdiem wants to merge 3 commits into
Open
London | 26-SDC-March | Jamal Laqdiem| Sprint 2 | Improve code with caches#214jamallaqdiem wants to merge 3 commits into
jamallaqdiem wants to merge 3 commits into
Conversation
cjyuan
reviewed
Jul 14, 2026
Comment on lines
+36
to
+37
| ways_to_make_change_helper(total - current_coin, coins, coin_index) + | ||
| ways_to_make_change_helper(total, coins, coin_index + 1) |
There was a problem hiding this comment.
The original "loop" version and your "without loop" version differ in terms of how deep the recursion can go, which affects the amount of stack space required at runtime. For a large total, the program may exceed the available stack space and fail.
Could you update your code to match the original approach as much as possible?
Notes:
- Supposedly, one level of loop is enough.
- When there is only one coin left to consider, there is a much quicker way to figure out if there is 0 or 1 way to make the change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Self checklist
Changelist
Optimised both exercises using local function caches and index-based tracking to eliminate global scope variables and slow array allocations