cpp implementation of Word Ladder