Favourite Shared Choice
mine and yours are two lists of restaurant names, each ordered from most to least liked, with no name repeated inside a list. For a restaurant that appears in both lists, its rank sum is its position in mine plus its position in yours (positions start at 0).
Return every shared restaurant whose rank sum is the smallest, sorted alphabetically. If the two lists share no restaurant, return [].
Example 1
mine ["sushi","taco","pizza"]
yours ["pizza","sushi","ramen"]
returns ["sushi"]
sushi has rank sum 0 + 1 = 1 and pizza has 2 + 0 = 2, so sushi wins.
Example 2
mine ["a","b","c"]
yours ["c","b","a"]
returns ["a","b","c"]
a, b and c all have rank sum 2, so all three are returned in alphabetical order.
Constraints
0 <= len(mine) <= 100and0 <= len(yours) <= 100- names are 1 to 10 lowercase letters
- no name appears twice in the same list
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.