How to solve this?

I was trying to solve the following dynamic programming problem but couldn’t figure out the solution. Can anyone please help me? I have seen such type of problems before but don’t understand the general pattern behind their solution.

1 Like

@everule1 Please help.

You just have to find the number of ways to get j mod 13 from the first i digits. To add a new digit d to the right, j mod 13 becomes 10j+d mod 13. If it’s a ?, then you have to do it for all d from 0 to 9.

1 Like

Alright. I’ll try coding up a solution. Thanks.