当前位置:网站首页>Force buckle 599 Minimum index sum of two lists
Force buckle 599 Minimum index sum of two lists
2022-07-07 20:06:00 【Tomorrowave】
599. The minimum index sum of two lists
hypothesis Andy and Doris Want to choose a restaurant for dinner , And they all have a list of their favorite restaurants , The name of each restaurant is represented by a string .
You need to help them use the least index and find their favorite restaurants . If there is more than one answer , Then all the answers are output regardless of the order . You can assume that the answer always exists .
Knowledge points involved :
Dictionaries
Code section
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
边栏推荐
- 九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
- R语言ggplot2可视化:使用ggpubr包的ggdensity函数可视化分组密度图、使用stat_overlay_normal_density函数为每个分组的密度图叠加正太分布曲线
- 力扣 1232.缀点成线
- 力扣 989. 数组形式的整数加法
- 力扣674. 最长连续递增序列
- pom. XML configuration file label: differences between dependencies and dependencymanagement
- vulnhub之Funfox2
- How to cooperate among multiple threads
- 毕业季|遗憾而又幸运的毕业季
- 力扣 1790. 仅执行一次字符串交换能否使两个字符串相等
猜你喜欢
干货分享|DevExpress v22.1原版帮助文档下载集合
Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!
开源重器!九章云极DataCanvas公司YLearn因果学习开源项目即将发布!
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
Make this crmeb single merchant wechat mall system popular, so easy to use!
项目经理『面试八问』,看了等于会了
微信公众号OAuth2.0授权登录并显示用户信息
vulnhub之school 1
Redis——基本使用(key、String、List、Set 、Zset 、Hash、Geo、Bitmap、Hyperloglog、事务 )
8 CAS
随机推荐
mock. JS returns an array from the optional data in the object array
R语言ggplot2可视化:使用ggpubr包的ggecdf函数可视化分组经验累积密度分布函数曲线、linetype参数指定不同分组曲线的线型
2022如何评估与选择低代码开发平台?
Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!
[sword finger offer] sword finger offer II 012 The sum of left and right subarrays is equal
BI的边界:BI不适合做什么?主数据、MarTech?该如何扩展?
R language ggplot2 visualization: use the ggdensity function of ggpubr package to visualize the packet density graph, and use stat_ overlay_ normal_ The density function superimposes the positive dist
LeetCode_7_5
力扣 1037.有效的回旋镖
【剑指offer】剑指 Offer II 012. 左右两边子数组的和相等
el-upload上传组件的动态添加;el-upload动态上传文件;el-upload区分文件是哪个组件上传的。
Mysql, sqlserver Oracle database connection mode
Training IX basic configuration of network services
力扣 1232.缀点成线
Welcome to the markdown editor
银行理财产品怎么买?需要办银行卡吗?
实训九 网络服务的基本配置
关于自身的一些安排
ASP. Net kindergarten chain management system source code
equals 方法