public class Solution {
public string[] FindRestaurant(string[] list1, string[] list2) {
var dic = new Dictionary<string, int>();
for (int i = ; i < list1.Length; i++)
{
for (int j = ; j < list2.Length; j++)
{
if (list1[i] == list2[j])
{
var restaurant = list1[i];
var index = i + j;
if (!dic.ContainsKey(restaurant))
{
dic.Add(restaurant, index);
}
}
}
} var minIndex = dic.Min(x => x.Value);
var list = dic.Where(x => x.Value == minIndex).Select(x => x.Key).ToList();
return list.ToArray();
}
}

https://leetcode.com/problems/minimum-index-sum-of-two-lists/#/description

leetcode599的更多相关文章

  1. [Swift]LeetCode599. 两个列表的最小索引总和 | Minimum Index Sum of Two Lists

    Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite ...

  2. Leetcode599.Minimum Index Sum of Two Lists

    假设Andy和Doris想在晚餐时选择一家餐厅,并且他们都有一个表示最喜爱餐厅的列表,每个餐厅的名字用字符串表示. 你需要帮助他们用最少的索引和找出他们共同喜爱的餐厅. 如果答案不止一个,则输出所有答 ...

随机推荐

  1. 32-THREE.JS 球体

    <!DOCTYPE html> <html> <head> <title>Example 05.05 - Basic 3D geometries - S ...

  2. 使用PorterDuffXfermode画出刮刮奖效果p146-p148

    package com.zzw.Qunyinzghuan3; import android.content.Context; import android.graphics.Bitmap; impor ...

  3. nivicat premium连接阿里云数据库

    1.首先打开Navicat,文件>新建连接>MySQL连接,其他的如一图所示 其中: 连接名:自己取一个名字 主机名:填写mysql的地址 用户名:mysql的登录的用户名 密码:登录的密 ...

  4. UI - 视图控制器跳转另一个视图控制器特效总结

    1. 从一个视图控制器跳转另一个视图控制器的方式是可以进行设置的 CATransition *animation = [[CATransition alloc]init]; animation.dur ...

  5. http://www.cnblogs.com/peida/archive/2013/05/31/3070790.html深入理解Java:SimpleDateFormat安全的时间格式化

    http://www.cnblogs.com/peida/archive/2013/05/31/3070790.html

  6. css3 hover 效果

    链接 链接 链接 链接 大量级 11 22  类似拉勾  33 包括各种流行的hover 小众 极光

  7. AAC解码算法原理详解

  8. 目标跟踪之ECO:Efficient Convolution Operators for Tracking

    一. 相关滤波算法总结 作者首先分析了 影响相关滤波算法效率 和 导致过拟合 的几个原因: 1)Model Size (模型大小) 包括两个方面: - 模型层数,对应多分辨率 Sample,比如多层 ...

  9. Azure VM Scalable Sets -- 适用IAAS架构

    1. 选择Virtual Machine scale set2. 选择resource manager(或创建最新)3. 基本信息配置4. 配置scale的参数(可伸缩的balance模型):VM最小 ...

  10. OpenGL ES 2: debugging, and improvements to VAO, VBO

    OpenGL ES 2: debugging, and improvements to VAO, VBO http://www.altdevblogaday.com/2013/10/12/opengl ...