Count of ways to split a given number into prime segments

isme main same tareeka use kr ra tha as that of finding substrings nikal ra tha
pr dp kaise impleent kru
aur reduntant sets ko hata na
unique count krne h

Code: https://ide.codingblocks.com/s/328510


Please refer to this link.

Pls explain how the dp is implemente. I am unable to understand it.

Did you understand the simple recursive approach?

yes, it is like in “3175”, we first check if 3 is prime then we will check in the rest of “175” using recusrion, similarly we will continue, then we will move to next index and we will see if 31 is prime then we will check for rest “75” using recursion

Yes right. In our recursive function, there is just one changing factor, which is i. So we need 1-D DP only. And then we apply simple memoization as done before.

but what we need to memoize like, for ith index, what should we remember

We store the value our function is returning for that particular index. This is done so that it is not computed again and again.

I mean to ask that like something (eg: susets, etc) at ith index etc.

It returns a single value, the number of subsets possible. The value which is asked in the question.

ok thanks will see to it. THanks for help

Welcome. Please mark your doubt as resolved now.