Shortest Word Distance II
Input:
word1
=
“coding”
,
word2
=
“practice”
Output:
3Input:
word1
=
"makes"
,
word2
=
"coding"
Output:
1Analysis
Solution
Location mapping, and brute force two nested for loops
Optimized - using two pointers
Reference
Last updated