/runs the shortest path calculation from the adjacency mapreturning vector /that contains the sequence of word changes to get from first to second unordered_map findchainconst unordered_mapadjacentwordsconst string firstconst string second unordered_map previouswordqueue qq pushfirst )while! emptystring current front) pop)auto itr adjacentwords findcurrent )const vector adj itr->secondforstring str adj ifpreviouswordstr ="previouswordstr currentq pushstr )previouswordfirst ""return previousword/after the shortest path calculation has runcomputes the vector that /contains the sequence of words changes to get from first to second vector getchainfrompreviousmapconst unordered_map previousconst string second vector resultauto prev const_cast &>previous )forstring current secondcurrent !""current prevcurrent result push_backcurrent )reversebeginresult )endresult )return resultfigure +code to find word ladders