java.lang.Object
g0501_0600.s0599_minimum_index_sum_of_two_lists.Solution

public class Solution extends Object
599 - Minimum Index Sum of Two Lists.<p>Easy</p> <p>Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings.</p> <p>You need to help them find out their <strong>common interest</strong> with the <strong>least list index sum</strong>. If there is a choice tie between answers, output all of them with no order requirement. You could assume there always exists an answer.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> list1 = [&ldquo;Shogun&rdquo;,&ldquo;Tapioca Express&rdquo;,&ldquo;Burger King&rdquo;,&ldquo;KFC&rdquo;], list2 = [&ldquo;Piatti&rdquo;,&ldquo;The Grill at Torrey Pines&rdquo;,&ldquo;Hungry Hunter Steakhouse&rdquo;,&ldquo;Shogun&rdquo;]</p> <p><strong>Output:</strong> [&ldquo;Shogun&rdquo;]</p> <p><strong>Explanation:</strong> The only restaurant they both like is &ldquo;Shogun&rdquo;.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> list1 = [&ldquo;Shogun&rdquo;,&ldquo;Tapioca Express&rdquo;,&ldquo;Burger King&rdquo;,&ldquo;KFC&rdquo;], list2 = [&ldquo;KFC&rdquo;,&ldquo;Shogun&rdquo;,&ldquo;Burger King&rdquo;]</p> <p><strong>Output:</strong> [&ldquo;Shogun&rdquo;]</p> <p><strong>Explanation:</strong> The restaurant they both like and have the least index sum is &ldquo;Shogun&rdquo; with index sum 1 (0+1).</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= list1.length, list2.length <= 1000</code></li> <li><code>1 <= list1[i].length, list2[i].length <= 30</code></li> <li><code>list1[i]</code> and <code>list2[i]</code> consist of spaces <code>' '</code> and English letters.</li> <li>All the stings of <code>list1</code> are <strong>unique</strong>.</li> <li>All the stings of <code>list2</code> are <strong>unique</strong>.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details