当前位置:网站首页>leetcode:2032. Values that appear in at least two arrays
leetcode:2032. Values that appear in at least two arrays
2022-07-31 13:46:00 【Soft-hearted and cool】
Difficulty: Easy
Give you three integer arrays nums1, nums2 and nums3, please construct and return an array with different elements, and by at least two arrays appearing in the arrayall values.Elements in an array can be in any order.
Example 1:
Input:nums1 = [1,1,3,2], nums2 = [2,3], nums3 = [3]Output:[3,2]Explanation: All values that appear in at least two arrays are:- 3 , which occurs in all three arrays.- 2 , which appeared in the arrays nums1 and nums2.Example 2:
Input:nums1 = [3,1], nums2 = [2,3], nums3 = [1,2]Output:[2,3,1]Explanation: All values that appear in at least two arrays are:- 2 , which appeared in the arrays nums2 and nums3 .- 3 , which appeared in the arrays nums1 and nums2.- 1 , which appeared in arrays nums1 and nums3.Example 3:
Input:nums1 = [1,2,2], nums2 = [4,3,3], nums3 = [5]Output:[]Explanation: There is no value that appears in at least two arrays.Tip:
1 <= nums1.length, nums2.length, nums3.length <= 100
1 <= nums1[i], nums2[j], nums3[k] <= 100Solution:
class Solution:def twoOutOfThree(self, nums1: List[int], nums2: List[int], nums3: List[int]) -> List[int]:_list = []res = []for i in nums1:_list.append(i)for j in nums2:_list.append(j)for k in nums3:_list.append(k)a = set(_list)a = list(a)for s in a:if (s in nums1 and s in nums2 ) or (s in nums1 and s in nums3) or (s in nums2 and s in nums3) or (s in nums1 and s in nums2 and s in nums3):res.append(s)set(res)list(res)return res
边栏推荐
猜你喜欢

Spark Learning: Add Custom Optimization Rules for Spark Sql

VU 非父子组件通信

报错IDEA Terminated with exit code 1

Grab the tail of gold, silver and silver, unlock the programmer interview "Artifact of Brushing Questions"

ECCV 2022 | 机器人的交互感知与物体操作

Linux bash: redis-server: 未找到命令

An article makes it clear!What is the difference and connection between database and data warehouse?

对数字化时代的企业来说,数据治理难做,但应该去做

All-round visual monitoring of the Istio microservice governance grid (microservice architecture display, resource monitoring, traffic monitoring, link monitoring)

推荐系统-召回阶段-2013:DSSM(双塔模型)【Embedding(语义向量)召回】【微软】
随机推荐
六石编程学:不论是哪个功能,你觉得再没用,会用的人都离不了,所以至少要做到99%
C# control StatusStrip use
Use of C# Assembly
EasyMock日记1[通俗易懂]
EXCEL如何快速拆分合并单元格数据
ECCV2022: Recursion on Transformer without adding parameters and less computation!
How to quickly split and merge cell data in Excel
Miller_Rabin 米勒拉宾概率筛【模板】
拥塞控制,CDN,端到端
[Niu Ke brush questions - SQL big factory interview questions] NO3. E-commerce scene (some east mall)
滑窗法切分数据
mysql8, starttime的下一个值作为endtime的上一个值?
全局平均池化层替代全连接层(最大池化和平均池化的区别)
The operator,
csdn发文助手问题
C#Assembly的使用
Selenium自动化测试之Selenium IDE
百度网盘安装在c盘显示系统权限限制的解决方法
IDEA如何运行web程序
How IDEA runs web programs