Created
January 17, 2013 13:12
-
-
Save rajkumar-p/4555854 to your computer and use it in GitHub Desktop.
Build ladder data structure
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
| void buildLadderDataStructure(vector<element> &wordListDS) | |
| { | |
| int wordListSize = wordListDS.size(); | |
| for (int i = 0; i < wordListSize; ++i) | |
| { | |
| for (int j = i + 1; j < wordListSize; ++j) | |
| { | |
| element e1 = wordListDS.at(i); | |
| element e2 = wordListDS.at(j); | |
| int diff = getDiffCount(e1.word, e2.word); | |
| if (diff == 1) { | |
| wordListDS.at(i).links.push_back(&wordListDS.at(j)); | |
| wordListDS.at(j).links.push_back(&wordListDS.at(i)); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment