Back to course home
0% completed
Vote For New Content
I think this solution needs a part explaining why exactly this algorithm works
Dmitry Gachkovsky
Dec 3, 2023
Because to me it's not intuitive why by jumping with the pointers to any found instances of word1or word2 we guaranteed to handle all the cases and get the shortest distance
0
0
Comments
Comments
J
Jack Tan2 months ago
Scanning left→right, position1 and position2 are the latest indices of word1 and word2. If position2 updates to position2′ while position1 stays, comparing dist(position1, position2′) to the current minimum suffices, since any earlier word1 index (left...