599. Minimum Index Sum of Two Lists Easy
1/**
2 * [599] Minimum Index Sum of Two Lists
3 *
4 * Given two arrays of strings list1 and list2, find the common strings with the least index sum.
5 * A common string is a string that appeared in both list1 and list2.
6 * A common string with the least index sum is a common string such that if it appeared at list1[i] and list2[j] then i + j should be the minimum value among all the other common strings.
7 * Return all the common strings with the least index sum. Return the answer in any order.
8 *
9 * Example 1:
10 *
11 * Input: list1 = ["Shogun","Tapioca Express","Burger King","KFC"], list2 = ["Piatti","The Grill at Torrey Pines","Hungry Hunter Steakhouse","Shogun"]
12 * Output: ["Shogun"]
13 * Explanation: The only common string is "Shogun".
14 *
15 * Example 2:
16 *
17 * Input: list1 = ["Shogun","Tapioca Express","Burger King","KFC"], list2 = ["KFC","Shogun","Burger King"]
18 * Output: ["Shogun"]
19 * Explanation: The common string with the least index sum is "Shogun" with index sum = (0 + 1) = 1.
20 *
21 * Example 3:
22 *
23 * Input: list1 = ["happy","sad","good"], list2 = ["sad","happy","good"]
24 * Output: ["sad","happy"]
25 * Explanation: There are three common strings:
26 * "happy" with index sum = (0 + 1) = 1.
27 * "sad" with index sum = (1 + 0) = 1.
28 * "good" with index sum = (2 + 2) = 4.
29 * The strings with the least index sum are "sad" and "happy".
30 *
31 *
32 * Constraints:
33 *
34 * 1 <= list1.length, list2.length <= 1000
35 * 1 <= list1[i].length, list2[i].length <= 30
36 * list1[i] and list2[i] consist of spaces ' ' and English letters.
37 * All the strings of list1 are unique.
38 * All the strings of list2 are unique.
39 *
40 */
41pub struct Solution {}
42
43// problem: https://leetcode.com/problems/minimum-index-sum-of-two-lists/
44// discuss: https://leetcode.com/problems/minimum-index-sum-of-two-lists/discuss/?currentPage=1&orderBy=most_votes&query=
45
46// submission codes start here
47
48impl Solution {
49 pub fn find_restaurant(list1: Vec<String>, list2: Vec<String>) -> Vec<String> {
50 vec![]
51 }
52}
53
54// submission codes end
55
56#[cfg(test)]
57mod tests {
58 use super::*;
59
60 #[test]
61 fn test_599() {
62 }
63}
64
Back
© 2025 bowen.ge All Rights Reserved.