I have been trying to find the recursive solution for SPOJ BORW(Black or White) problem , but none of the recursive logic seems to work.
I understood that the recursive equation will be based on the logic that any ball can be either painted black or white or none , but couldn’t turn it into logical terms .
Problem link link text
Since recurisve solution has been provided now , I was trying to convert this solution to dp solution using 3D dp array of which one of the state whould be array index. For the next two states I am little confused bcoz if I take array values as the other two indexes , then the dp size would be too large . Any suggestion what should be the other two states of dp ??
Any hints will be appreciated. Thanks