当前位置:网站首页>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
边栏推荐
- Save and load numpy matrices and vectors, and use the saved vectors for similarity calculation
- 战略进攻能力的重要性,要远远高于战略防守能力
- 计算机复试面试问题(计算机面试常见问题)
- 【牛客刷题-SQL大厂面试真题】NO3.电商场景(某东商城)
- Sliding window method to segment data
- PHP Serialization: eval
- Detailed explanation of network protocols and related technologies
- ECCV 2022 | Robotic Interaction Perception and Object Manipulation
- 浏览器被hao360劫持解决办法
- What should I do if selenium is reversed?
猜你喜欢

C#控件 ToolStripProgressBar 用法

ECCV2022:在Transformer上进行递归,不增参数,计算量还少!

PHP Serialization: eval

八大排序汇总及其稳定性

pytorch gpu版本安装最新

「面经分享」西北大学 | 字节 生活服务 | 一面二面三面 HR 面

365-day challenge LeetCode1000 questions - Day 044 Maximum element in the layer and level traversal

Spark Learning: Add Custom Optimization Rules for Spark Sql

C#控件ListView用法

抓住金三银四的尾巴,解锁程序员面试《刷题神器》
随机推荐
ECCV2022:在Transformer上进行递归,不增参数,计算量还少!
C#高级--委托
计算机复试面试问题(计算机面试常见问题)
自制的数据库安全攻防题,相关靶机自己制作
技能大赛训练题:ftp 服务攻防与加固
Selenium自动化测试之Selenium IDE
抓住金三银四的尾巴,解锁程序员面试《刷题神器》
Four ways to clear the float and its principle understanding
图像大面积缺失,也能逼真修复,新模型CM-GAN兼顾全局结构和纹理细节
SetoolKit使用指南
C语言基础练(九九乘法表)与打印不同星号图案
Flutter keyboard visibility
求一份常见Oracle故障模拟场景
SAP 电商云 Spartacus UI 和 Accelerator UI 里的 ASM 模块
selenium被反爬了怎么办?
滑窗法切分数据
C#控件CheckBox的使用
ADS与C#通信
Install the latest pytorch gpu version
PHP序列化:eval