Skip to content
Advertisement

Memoization using dictionary

So I am trying to implement Lowest common subsequence in Python and was trying this alternative to my previous solution. I tried using a dictionary instead of a 2-D matrix to memoize the results.

JavaScript

It’s returning

JavaScript

which I understand is because I am not returning anything so how can I do something like this.

JavaScript

And I am trying to implement it without using any decorators.

Advertisement

Answer

Try this

JavaScript
Advertisement