当前位置:网站首页>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
边栏推荐
- ADS communicate with c #
- The latest complete code: Incremental training using the word2vec pre-training model (two loading methods corresponding to two saving methods) applicable to various versions of gensim
- MySQL玩到这种程度,难怪大厂抢着要!
- AI cocoa AI frontier introduction (7.31)
- [Niu Ke brush questions - SQL big factory interview questions] NO3. E-commerce scene (some east mall)
- 龟速乘【模板】
- The batch size does not have to be a power of 2!The latest conclusions of senior ML scholars
- leetcode:2032. 至少在两个数组中出现的值
- 基于改进YOLOv5的轻量化航空目标检测方法
- Solution for browser hijacking by hao360
猜你喜欢

Even if the image is missing in a large area, it can also be repaired realistically. The new model CM-GAN takes into account the global structure and texture details

C# Get network card information NetworkInterface IPInterfaceProperties

一篇文章讲清楚!数据库和数据仓库到底有什么区别和联系?

【牛客刷题-SQL大厂面试真题】NO3.电商场景(某东商城)

Detailed explanation of network protocols and related technologies

How IDEA runs web programs

3.爬虫之Scrapy框架1安装与使用

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

golang-gin-pprof-使用以及安全问题

How to quickly split and merge cell data in Excel
随机推荐
[Niu Ke brush questions - SQL big factory interview questions] NO3. E-commerce scene (some east mall)
C# control ListView usage
C#控件StatusStrip使用
Productivity Tools and Plugins
网络层重点协议——IP协议
Istio微服务治理网格的全方面可视化监控(微服务架构展示、资源监控、流量监控、链路监控)
Introduction to the PartImageNet Semantic Part Segmentation dataset
endnote引用
IDEA如何运行web程序
基于高阶微分器的无模型滑模控制器及其在自动电压调节器中的应用
关于MySQL主从复制的数据同步延迟问题
Shell脚本经典案例:文件的备份
动作捕捉系统用于柔性机械臂的末端定位控制
爱可可AI前沿推介(7.31)
0X7FFFFFFF,0X80000000「建议收藏」
The operator,
EXCEL如何快速拆分合并单元格数据
JSP中如何借助response对象实现页面跳转呢?
ICML2022 | Fully Granular Self-Semantic Propagation for Self-Supervised Graph Representation Learning
机器学习模型验证:被低估的重要一环