Why am i getting an error?

You should have 3 states in dp for i,j,k.

can u correct my code?

U should have 3 states but in ur code u have taken only two states. Try to correct it.

If u face problem then u can refer this code: