当前位置:网站首页>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
边栏推荐
- C语言基础练(九九乘法表)与打印不同星号图案
- 计算机复试面试问题(计算机面试常见问题)
- 基于高阶微分器的无模型滑模控制器及其在自动电压调节器中的应用
- 文本相似度计算(中英文)详解实战
- golang-gin-优雅重启
- The use of C# control CheckBox
- 技能大赛训练题:MS15_034漏洞验证与安全加固
- P5019 [NOIP2018 提高组] 铺设道路
- The importance of strategic offensive capability is much higher than strategic defensive capability
- DELL SC compellent 康贝存储系统怎么抓取配置信息
猜你喜欢

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

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

pytorch gpu版本安装最新

PHP Serialization: eval

C#高级--委托

Spark Learning: Add Custom Optimization Rules for Spark Sql
![[CPU Design Practice] Simple Pipeline CPU Design](/img/83/e1dfedfe2b2cfe83a34f86e252caa7.jpg)
[CPU Design Practice] Simple Pipeline CPU Design

hyperf的启动源码分析(二)——请求如何到达控制器

ADS communicate with c #

AI cocoa AI frontier introduction (7.31)
随机推荐
C# List Usage List Introduction
Network layer key protocol - IP protocol
3.爬虫之Scrapy框架1安装与使用
Selenium自动化测试之Selenium IDE
战略进攻能力的重要性,要远远高于战略防守能力
线程池的使用二
C语言基础练(九九乘法表)与打印不同星号图案
Miller_Rabin 米勒拉宾概率筛【模板】
【牛客刷题-SQL大厂面试真题】NO3.电商场景(某东商城)
hyperf的启动源码分析(二)——请求如何到达控制器
页面整屏滚动效果
ECCV 2022 | 机器人的交互感知与物体操作
基于改进YOLOv5的轻量化航空目标检测方法
Error IDEA Terminated with exit code 1
C# Get network card information NetworkInterface IPInterfaceProperties
分布式锁有哪些,怎么实现(分布式锁的三种实现的对比)
The operator,
golang-gin-优雅重启
C# using NumericUpDown control
基于神经网络的多柔性梁耦合结构振动控制