[Community Puzzle] Rod cutting problem

It’s not a CG bug, the runtime of your solution is almost exactly the same as the timelimit so sometimes you pass and sometimes you fail. Your solution is still O(L* L) and the more optimal solutions (O(L*N)) run about 10x faster and never get close to the timelimit.

1 Like

YOU SAVED MY DAY !
Found how to do it thanks to this book.
:star_struck: :star_struck: :star_struck: :star_struck: :star_struck:
solved with 15 lines now

In Java the last test ends up with the stack overflow error as well (with memorization approach).

I think that there is no issue with the tests, but description of this puzzle is misleading.

It states that puzzle has to be solved using MEMORIZATION and that is impossible due to memory limitations.

TABULATION works fine for this puzzle, not MEMORIZATION.

No one ever said or implied memorization is the only approach to solve it.
The tags only indicate a puzzle can be related to certain algorithms or skill sets.

The suggested approach may not always work for everyone because it depends on one’s implementation.

Tabulation (bottom up approach) and memorization (top down approach) both have quite identical time complexity.
But memorization approach significantly increases space complexity regardless the language you are using or peculiarities of the implementation.

You are trying to convey that it is OK that the tag that is attached to a puzzle does not necessarily connected with actual technics applicable to the problem?
(when I say applicable, I mean one that enable to pass all the tests)