cpp implementation of Word Break II