599Minimum Index Sum of Two Lists
来源:互联网 发布:绝对伏特加 知乎 编辑:程序博客网 时间:2024/05/17 22:36
class Solution(object):
def findRestaurant(self, A, B):
"""
:type list1: List[str]
:type list2: List[str]
:rtype: List[str]
"""
dic={u:i for i,u in enumerate(A)}
best, ans = 10000, []
for j in range(len(B)):
if B[j] in dic:
i = dic[B[j]]
if i + j < best:
best = i + j
ans = [B[j]]
elif i + j == best:
ans.append(B[j])
def findRestaurant(self, A, B):
"""
:type list1: List[str]
:type list2: List[str]
:rtype: List[str]
"""
dic={u:i for i,u in enumerate(A)}
best, ans = 10000, []
for j in range(len(B)):
if B[j] in dic:
i = dic[B[j]]
if i + j < best:
best = i + j
ans = [B[j]]
elif i + j == best:
ans.append(B[j])
return ans
找两列表中下表和最小的元素
阅读全文
0 0
- 599Minimum 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
- 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
- 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
- leetode.599. Minimum Index Sum of Two Lists
- LeetCode 599. Minimum Index Sum of Two Lists(map,unordered_map)
- 知识图谱技术分享会----有关知识图谱构建的部分关键技术简介及思考
- 整除7,9,11的数的性质
- java语言---一维数组要点
- VR系列——Oculus Rift 开发者指南:四、高级渲染配置(二)
- 微信公众号开始运营了
- 599Minimum Index Sum of Two Lists
- bzoj1786: [Ahoi2008]Pair 配对
- FUNDAMENTAL Unit02 变量 、 JAVA基本类型
- CMS收集器和G1收集器优缺点
- python request快速上手
- 11-JavaScript设计模式——享元模式
- mysql常用操作小节
- CentOS7下手动配本地yum源
- C#添加属性快捷键、类和对象