implement q2 in word_break in leetcode