Dynamic Programming and Depth First Search to Break Word