当前位置:网站首页>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
边栏推荐
- Some important knowledge of MySQL
- 【Confluence】JVM内存调整
- 力扣599. 两个列表的最小索引总和
- LeetCode力扣(剑指offer 36-39)36. 二叉搜索树与双向链表37. 序列化二叉树38. 字符串的排列39. 数组中出现次数超过一半的数字
- 项目经理『面试八问』,看了等于会了
- BI的边界:BI不适合做什么?主数据、MarTech?该如何扩展?
- PMP对工作有益吗?怎么选择靠谱平台让备考更省心省力!!!
- gorilla官方:golang开websocket client的示例代码
- 小试牛刀之NunJucks模板引擎
- 力扣 1790. 仅执行一次字符串交换能否使两个字符串相等
猜你喜欢
Ways to improve the utilization of openeuler resources 01: Introduction
关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
9 atomic operation class 18 Rohan enhancement
干货分享|DevExpress v22.1原版帮助文档下载集合
mysql 的一些重要知识
LeetCode_7_5
项目经理『面试八问』,看了等于会了
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
ASP. Net kindergarten chain management system source code
PMP practice once a day | don't get lost in the exam -7.7
随机推荐
MSE API学习
Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!
IP 工具类
RESTAPI 版本控制策略【eolink 翻译】
国家网信办公布《数据出境安全评估办法》:累计向境外提供10万人信息需申报
R语言ggplot2可视化:使用ggpubr包的ggdensity函数可视化分组密度图、使用stat_overlay_normal_density函数为每个分组的密度图叠加正太分布曲线
pom. XML configuration file label: differences between dependencies and dependencymanagement
开源OA开发平台:合同管理使用手册
R语言ggplot2可视化:使用ggpubr包的ggstripchart函数可视化分组点状条带图(dot strip plot)、设置position参数配置不同分组数据点的分离程度
剑指 Offer II 013. 二维子矩阵的和
模拟实现string类
Redis——基本使用(key、String、List、Set 、Zset 、Hash、Geo、Bitmap、Hyperloglog、事务 )
The DBSCAN function of FPC package of R language performs density clustering analysis on data, checks the clustering labels of all samples, and the table function calculates the two-dimensional contin
equals 方法
Some arrangements about oneself
项目经理『面试八问』,看了等于会了
Browse the purpose of point setting
Leetcode force buckle (Sword finger offer 36-39) 36 Binary search tree and bidirectional linked list 37 Serialize binary tree 38 Arrangement of strings 39 Numbers that appear more than half of the tim
【剑指offer】剑指 Offer II 012. 左右两边子数组的和相等
ASP. Net gymnasium integrated member management system source code, free sharing