Is recursion + memoization enough? or do i need to fold out the DP too?
Anonymous User
2345

Generally I solve the DP problem by solving with recursion first. Which by default gets TLE. Then i apply the memoization to cache the sub problem state. These two steps come naturally to me.

Third step is usually to convert it to DP tabulation.

The problem is I can simulate the first two steps pretty first for any new problem. But coming with direct DP tabulation solution hasn't been a my thing yet. So i guess in the interview pressure scenario i will by nature go to recursion + memoization way. As there is a time limit i might not come with the final step which is DP part. Although usually TC remains always same whether in recursion + memoization or standalone DP (For DP sometimes SC can be improved).

So my question is : Is coming up with recursion + memoization solution in an interview enough? Or I should always come with direct DP part in the interview?

Thanks.

Update: Recently i stumbled upon an ex-google interviewer post and his thought process of giving "Strong Hire" "Hire" and "No Hire" recommendations. Luckily he explained the process with a problem which fits my question criteria perfectly. So as it gets the DP tabludation is the answer. There are some major drawback even with recursion+memoization.

Here is the post link: https://alexgolec.dev/google-interview-questions-deconstructed-the-knights-dialer/

Comments (6)