[leetCode刷题笔记]599. Minimum Index Sum of Two Lists
来源:互联网 发布:powell算法 编辑:程序博客网 时间:2024/05/20 06:10
public class Solution { public String[] findRestaurant(String[] list1, String[] list2) { int i = 0; i = 0; Map<String, Integer> map2 = new HashMap<String, Integer>(); for (String ele : list2 ) { map2.put(ele, i++); } int min = Integer.MAX_VALUE; i = 0; for (String ele : list1) { if (map2.containsKey(ele)) { if (map2.get(ele) + i < min ) min = map2.get(ele) + i; } i++; } i = 0; LinkedList<String> res = new LinkedList<String>(); for (String ele : list1) { if (map2.containsKey(ele)) { if (map2.get(ele) + i == min ) res.add(ele); } i++; } return res.toArray(new String[res.size()]); }}
阅读全文
0 0
- [leetCode刷题笔记]599. Minimum Index Sum of Two Lists
- [leetcode] 599. Minimum Index Sum of Two Lists
- leetcode 599. Minimum Index Sum of Two Lists
- LeetCode 599. Minimum Index Sum of Two Lists(map,unordered_map)
- LeetCode-599. Minimum Index Sum of Two Lists
- Leetcode-599.Minimum Index Sum of Two Lists
- leetcode 599. Minimum Index Sum of Two Lists
- [LeetCode]599. Minimum Index Sum of Two Lists
- LeetCode 599. Minimum Index Sum of Two Lists
- 【LeetCode】599. Minimum Index Sum of Two Lists
- leetcode 599. Minimum Index Sum of Two Lists
- 599. Minimum Index Sum of Two Lists
- 599. Minimum Index Sum of Two Lists
- 599. Minimum Index Sum of Two Lists
- 599. Minimum Index Sum of Two Lists
- 599. Minimum Index Sum of Two Lists
- 599. Minimum Index Sum of Two Lists
- 599. Minimum Index Sum of Two Lists
- Android 获取联系人手机号码、姓名、地址、公司、邮箱、生日
- Android 剔除手机联系人,添加手机联系人,更新手机联系人信
- 2017计蒜客复赛签到题
- list删除重复数据
- 在macOS Sierra 10.12.3下用VMware Fusion安装Ubuntu 16.04.2
- [leetCode刷题笔记]599. Minimum Index Sum of Two Lists
- Linux安装Apache
- 图论算法之最短路径(具有负边值的图)
- Android_常用控件
- C语言.动态链表.随笔
- 图论算法之最短路径(Dijkstra算法)
- 图论算法之最短路径(有向无权图)
- 《C语言及程序设计初步》_1.11算术运算符与算术表达式_实践11——如何买玫瑰
- 操作系统实验报告 lab6