当前位置:网站首页>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
边栏推荐
猜你喜欢

C#控件CheckBox的使用
![[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)

ECCV2022: Recursion on Transformer without adding parameters and less computation!

IDEA找不到Database解决方法

技能大赛dhcp服务训练题

Detailed explanation of network protocols and related technologies

csdn发文助手问题

技能大赛训练题:域用户和组织单元的创建

ECCV 2022 | Robotic Interaction Perception and Object Manipulation

操作符详解
随机推荐
为什么 wireguard-go 高尚而 boringtun 孬种
ADS与C#通信
AWS实现定时任务-Lambda+EventBridge
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
Error IDEA Terminated with exit code 1
endnote引用
C# using ComboBox control
页面整屏滚动效果
百度网盘安装在c盘显示系统权限限制的解决方法
Samba 远程命令执行漏洞(CVE-2017-7494)
报错:npm ERR code EPERM
滑窗法切分数据
Unity study notes Description of AVPro video jump function (Seeking)
如何使用StarUML画类图[通俗易懂]
Use of C# Assembly
C#控件StatusStrip使用
[RPI]树莓派监控温度及报警关机保护「建议收藏」
golang-gin-优雅重启
一篇文章讲清楚!数据库和数据仓库到底有什么区别和联系?
线程池的使用二