当前位置:网站首页>力扣599. 两个列表的最小索引总和
力扣599. 两个列表的最小索引总和
2022-07-07 17:53:00 【Tomorrowave】
599. 两个列表的最小索引总和
假设 Andy 和 Doris 想在晚餐时选择一家餐厅,并且他们都有一个表示最喜爱餐厅的列表,每个餐厅的名字用字符串表示。
你需要帮助他们用最少的索引和找出他们共同喜爱的餐厅。 如果答案不止一个,则输出所有答案并且不考虑顺序。 你可以假设答案总是存在。
涉及知识点:
字典
代码部分
class Solution:
def findRestaurant(self, list1: List[str], list2: List[str]) -> List[str]:
favorite_restaurant={
}
min_f=[]
for x in list1:
if x in list2:
favorite_restaurant[x]=list2.index(x)+list1.index(x)
minv=min(favorite_restaurant.values())
for i,j in favorite_restaurant.items():
if j==minv:
min_f.append(i)
return min_f
边栏推荐
- 2022年投资哪个理财产品收益高?
- torch. nn. functional. Pad (input, pad, mode= 'constant', value=none) record
- CSDN syntax description
- Browse the purpose of point setting
- how to prove compiler‘s correctness
- ASP.NET体育馆综合会员管理系统源码,免费分享
- 开源重器!九章云极DataCanvas公司YLearn因果学习开源项目即将发布!
- Mysql, sqlserver Oracle database connection mode
- Semantic slam source code analysis
- Some important knowledge of MySQL
猜你喜欢

vulnhub之Funfox2

Redis——基本使用(key、String、List、Set 、Zset 、Hash、Geo、Bitmap、Hyperloglog、事务 )

Introduction to bit operation

Open source heavy ware! Chapter 9 the open source project of ylarn causal learning of Yunji datacanvas company will be released soon!
Make this crmeb single merchant wechat mall system popular, so easy to use!

PMP每日一练 | 考试不迷路-7.7

Kirin Xin'an with heterogeneous integration cloud financial information and innovation solutions appeared at the 15th Hunan Financial Technology Exchange Conference

Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!

YoloV6:YoloV6+Win10---训练自己得数据集

LeetCode_7_5
随机推荐
华南X99平台打鸡血教程
LC:字符串转换整数 (atoi) + 外观数列 + 最长公共前缀
Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记
[sword finger offer] sword finger offer II 012 The sum of left and right subarrays is equal
Sword finger offer II 013 Sum of two-dimensional submatrix
Kunpeng developer summit 2022 | Kirin Xin'an and Kunpeng jointly build a new ecosystem of computing industry
Semantic slam source code analysis
项目经理『面试八问』,看了等于会了
Kubernetes——kubectl命令行工具用法详解
Visual Studio 插件之CodeMaid自动整理代码
Simulate the implementation of string class
CSDN语法说明
Notes...
IP 工具类
what‘s the meaning of inference
Training IX basic configuration of network services
My creation anniversary
9 atomic operation class 18 Rohan enhancement
2022如何评估与选择低代码开发平台?
pom.xml 配置文件标签作用简述