How do you develop an intuition for knowing what the params for the recursive helper function should be?

In going through the problems that follow the “Longest Common Substring” DP pattern, I noticed that for the top down solutions, sometimes we pass in a sum or a count into the params of the recursive helper method (e.g. for “Maximum Sum Increasing Subsequence”); while other times we do not.

Can someone help me understand HOW I can develop an intuition for when/when not to include a running total in the params? Thanks!

1 Like

Hi @Kash1215

Knowing what to use as a parameter while creating a recursive function that comes with an experience. If you want to get experience in that, I will suggest that you should convert all of for and while loop examples into recursive functions. Since each problem has different behavior, some functions will be getting something as a parameter and some will be performing the operation with the recursive function.

I hope I have answered your question but if there is still any query then please feel free to contact us again. Thanks.