Created
January 15, 2013 07:31
-
-
Save rajkumar-p/4536921 to your computer and use it in GitHub Desktop.
Naive algorithm to get the next words in a word ladder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| vector<string> getNextWordsForWord(string word, vector<string> wordList) | |
| { | |
| vector<string> nextWords; | |
| for (size_t i = 0; i < wordList.size(); ++i) | |
| { | |
| int diff = getDiffCount(word, wordList[i]); | |
| if (diff == 1) | |
| { | |
| nextWords.push_back(wordList[i]); | |
| } | |
| } | |
| return nextWords; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment