leetle

Daily challenge for 2025-06-15

166. Shortest Word Distance

Write a function solve that finds the shortest distance between two words in a list of words. Distance is the absolute difference between their indices.

Example:
Input: words = ["practice", "makes", "perfect", "coding", "makes"], word1 = "coding", word2 = "practice"
Output: 3

Run this challenge interactively in Python or JavaScript when the app loads.