当前位置:网站首页>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
边栏推荐
- 「面经分享」西北大学 | 字节 生活服务 | 一面二面三面 HR 面
- C#获得网卡信息 NetworkInterface IPInterfaceProperties
- golang-gin-pprof-使用以及安全问题
- C# Get network card information NetworkInterface IPInterfaceProperties
- Samba 远程命令执行漏洞(CVE-2017-7494)
- Detailed explanation of network protocols and related technologies
- 【蓝桥杯选拔赛真题46】Scratch磁铁游戏 少儿编程scratch蓝桥杯选拔赛真题讲解
- 深度剖析 Apache EventMesh 云原生分布式事件驱动架构
- 一篇文章讲清楚!数据库和数据仓库到底有什么区别和联系?
- 技能大赛训练题: 子网掩码划分案例
猜你喜欢

Spark Learning: Add Custom Optimization Rules for Spark Sql

Samba 远程命令执行漏洞(CVE-2017-7494)

networkx绘制度分布

C#控件CheckBox的使用

PartImageNet物体部件分割(Semantic Part Segmentation)数据集介绍
![[Niu Ke brush questions - SQL big factory interview questions] NO3. E-commerce scene (some east mall)](/img/a6/8d53f5087a33c2bea8c99a5bb922da.png)
[Niu Ke brush questions - SQL big factory interview questions] NO3. E-commerce scene (some east mall)

Golang - gin - pprof - use and safety

uniapp微信小程序引用标准版交易组件

关于MySQL主从复制的数据同步延迟问题

ICML2022 | Fully Granular Self-Semantic Propagation for Self-Supervised Graph Representation Learning
随机推荐
Shell脚本经典案例:探测批量主机是否存活
基于改进YOLOv5的轻量化航空目标检测方法
Error: npm ERR code EPERM
C#控件 ToolStripProgressBar 用法
Shell项目实战1.系统性能分析
ADS与C#通信
Golang - gin - pprof - use and safety
龟速乘【模板】
报错:npm ERR code EPERM
49.【拷贝构造函数与重载】
Detailed explanation of network protocols and related technologies
leetcode:485.最大连续 1 的个数
代码随想录笔记_哈希_454四数相加II
selenium被反爬了怎么办?
go使用makefile脚本编译应用
技能大赛训练题: 子网掩码划分案例
C# Get network card information NetworkInterface IPInterfaceProperties
AWS实现定时任务-Lambda+EventBridge
leetcode:2032. 至少在两个数组中出现的值
C#使用ComboBox控件