Skip to content

Instantly share code, notes, and snippets.

@rajkumar-p
Created January 15, 2013 15:28
Show Gist options
  • Save rajkumar-p/4539438 to your computer and use it in GitHub Desktop.
Save rajkumar-p/4539438 to your computer and use it in GitHub Desktop.
Initialize the vector of elements
// Maps a word to the index in the vector
map<string, int> wordToVectorIndex;
// Push the word to the vector
while (cin >> word)
{
element e;
e.word = word;
e.noOfLadders = 0;
e.isVisited = ELEMENT_NOT_VISITED;
e.distanceFromSource = 0;
wordListDS.push_back(e);
wordToVectorIndex[word] = wordIndex++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment