I was trying this question and this is the solution I came up with, but it timed out as it doesn't use memoization.
But I'm not getting the idea about how to memoize this solution. And I can't even find any good explanation for the question anywhere. Can someone please help?
Thanks.