当前位置:网站首页>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
边栏推荐
猜你喜欢

Flink并行度和Slot详解

使用高斯Redis实现二级索引

ASP. Net learning & ASP's one word

The state cyberspace Office released the measures for data exit security assessment: 100000 information provided overseas needs to be declared

CSDN语法说明

Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"

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

编译器优化那些事儿(4):归纳变量

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

Ways to improve the utilization of openeuler resources 01: Introduction
随机推荐
SQL common optimization
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
力扣 88.合并两个有序数组
【Confluence】JVM内存调整
Equals method
BI的边界:BI不适合做什么?主数据、MarTech?该如何扩展?
pom. Brief introduction of XML configuration file label function
How to cooperate among multiple threads
力扣 1037.有效的回旋镖
Navicat连接2002 - Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘解决
力扣 2319. 判断矩阵是否是一个 X 矩阵
LC: string conversion integer (ATOI) + appearance sequence + longest common prefix
Notes...
R语言fpc包的dbscan函数对数据进行密度聚类分析、查看所有样本的聚类标签、table函数计算聚类簇标签与实际标签构成的二维列联表
el-upload上传组件的动态添加;el-upload动态上传文件;el-upload区分文件是哪个组件上传的。
The project manager's "eight interview questions" is equal to a meeting
浏览积分设置的目的
mysql 的一些重要知识
Boot 和 Cloud 的版本选型
IP tools