cpp implementation of Word Break, may still can be optimized