check Word Break or not in dynamic programming