Skip to content

Instantly share code, notes, and snippets.

@rajkumar-p
Created January 15, 2013 07:31
Show Gist options
  • Save rajkumar-p/4536921 to your computer and use it in GitHub Desktop.
Save rajkumar-p/4536921 to your computer and use it in GitHub Desktop.
Naive algorithm to get the next words in a word ladder
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