indexMap
to store strings from list1
with their indices.list1
and populate indexMap
with each string and its index.minSum
to a large number and result
as an empty list.list2
, for each string:
a. Check if indexMap
contains the string.
b. If it does, calculate the index sum.
c. If the index sum is less than minSum
, update minSum
and reset result
with the current string.
d. If the index sum equals minSum
, append the current string to result
.result
list.