Help with a problem: Digit DP

I tried solving the following question:

This is my solution:

This works for all cases when I don’t use DP. But it gives WA when I use DP. I saw some solutions but I couldn’t understand where I’m wrong. Can someone explain where I’m wrong?

Indexing starts from the unit position.