Skip to content

Instantly share code, notes, and snippets.

@rajkumar-p
Created January 17, 2013 13:41
Show Gist options
  • Save rajkumar-p/4555979 to your computer and use it in GitHub Desktop.
Save rajkumar-p/4555979 to your computer and use it in GitHub Desktop.
Find the longest ladder using the ladder data structure
string findLongestLadder(vector<element> &wordListDS) {
int wordListSize = wordListDS.size();
int longestLadderSize= 0;
string longestLadder;
for (int i = 0; i < wordListSize; ++i) {
if (wordListDS.at(i).noOfLadders > longestLadderSize) {
longestLadderSize = wordListDS.at(i).noOfLadders;
longestLadder = wordListDS.at(i).word;
}
}
cout <<"Longest ladder size : "<<longestLadderSize<<endl;
return longestLadder;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment