Python 1 Line


  • 0
    return min(abs(x-y) for x in [i for i, w in enumerate(words) if w == word1] for y in [i for i, w in enumerate(words) if w == word2])

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.