Solved BadNeighbors problem with DP