当前位置:网站首页>leetcode:2032. 至少在两个数组中出现的值
leetcode:2032. 至少在两个数组中出现的值
2022-07-31 13:41:00 【心软且酷丶】
难度:简单
给你三个整数数组 nums1、nums2 和 nums3 ,请你构造并返回一个 元素各不相同的 数组,且由 至少 在 两个 数组中出现的所有值组成。数组中的元素可以按 任意 顺序排列。
示例 1:
输入:nums1 = [1,1,3,2], nums2 = [2,3], nums3 = [3] 输出:[3,2] 解释:至少在两个数组中出现的所有值为: - 3 ,在全部三个数组中都出现过。 - 2 ,在数组 nums1 和 nums2 中出现过。示例 2:
输入:nums1 = [3,1], nums2 = [2,3], nums3 = [1,2] 输出:[2,3,1] 解释:至少在两个数组中出现的所有值为: - 2 ,在数组 nums2 和 nums3 中出现过。 - 3 ,在数组 nums1 和 nums2 中出现过。 - 1 ,在数组 nums1 和 nums3 中出现过。示例 3:
输入:nums1 = [1,2,2], nums2 = [4,3,3], nums3 = [5] 输出:[] 解释:不存在至少在两个数组中出现的值。提示:
1 <= nums1.length, nums2.length, nums3.length <= 100
1 <= nums1[i], nums2[j], nums3[k] <= 100题解:
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
边栏推荐
- mysql8, starttime的下一个值作为endtime的上一个值?
- golang-gin-优雅重启
- C#控件 ToolStripProgressBar 用法
- ASM module in SAP Ecommerce Cloud Spartacus UI and Accelerator UI
- 动作捕捉系统用于柔性机械臂的末端定位控制
- MATLAB | 我也做了一套绘图配色可视化模板
- 最新完整代码:使用word2vec预训练模型进行增量训练(两种保存方式对应的两种加载方式)适用gensim各种版本
- STM32的CAN过滤器
- pytorch gpu版本安装最新
- 0X7FFFFFFF,0X80000000「建议收藏」
猜你喜欢
随机推荐
numpy矩阵和向量的保存与加载,以及使用保存的向量进行相似度计算
EasyMock日记1[通俗易懂]
go使用makefile脚本编译应用
LeetCode·每日一题·1161.最大层内元素和·层次遍历
endnote引用
Productivity Tools and Plugins
动作捕捉系统用于柔性机械臂的末端定位控制
ECCV 2022 | Robotic Interaction Perception and Object Manipulation
The cluster of safe mode
IDEA如何运行web程序
Samba 远程命令执行漏洞(CVE-2017-7494)
C#控件CheckBox的使用
JSP response对象简介说明
文本相似度计算(中英文)详解实战
[Niu Ke brush questions - SQL big factory interview questions] NO3. E-commerce scene (some east mall)
uniapp微信小程序引用标准版交易组件
生产力工具和插件
图像大面积缺失,也能逼真修复,新模型CM-GAN兼顾全局结构和纹理细节
ASM module in SAP Ecommerce Cloud Spartacus UI and Accelerator UI
Four ways to clear the float and its principle understanding


![[Niu Ke brush questions - SQL big factory interview questions] NO3. E-commerce scene (some east mall)](/img/a6/8d53f5087a33c2bea8c99a5bb922da.png)






