当前位置:网站首页>数组 求并集
数组 求并集
2022-06-10 20:50:00 【Morris_】
求两个数组的并集
- Swift
let nums1: [Int] = [1, 2, 2, 3, 4]
let nums2: [Int] = [2, 3, 2]
let nums = union(nums1, nums2)
print(nums)
func union(_ nums1: [Int], _ nums2: [Int]) -> [Int] {
var nums: [Int] = []
for i in 0..<nums1.count {
for j in 0..<nums2.count {
if nums1[i] == nums2[j] {
if nums.contains(nums1[i]) {
}
else {
nums.append(nums1[i])
}
break
}
}
}
return nums
}

边栏推荐
- 2022-06-09 RK817 PMU 电池温度检测
- The system needs to scan all the files and try to identify the cover of the video
- 2022-06-09 RK817 PMU 電池溫度檢測
- Asynchronous, thread pool (completablefuture)
- [nk] Niuke monthly race 51g calculation problem
- C language -- 11 branch statement if else
- Part 7: Lesson 2 general skills of consultants - how to install and uninstall SAP ERP system client
- C language learning review -- 1 basic knowledge review
- JS mobile terminal copy text to clipboard code
- Course design of imitation pottery ticket of wechat applet
猜你喜欢

Understanding of related concepts of target detection

Detailed explanation of Lora module wireless transceiver communication technology

标配双安全气囊,价格屠夫长安Lumin 4.89万起售

Naturalspeech model synthetic speech achieves human speech level for the first time in CMOS test

2022-06-09 rk817 PMU battery temperature detection

Interview Essentials - basic knowledge of synchronized underlying principles
![[Warning] TIMESTAMP with implicit DEFAULT value is deprecated](/img/e8/53c18a7944d160238f2f1c0f8f04b1.jpg)
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated

关于type-c

Standard dual airbags, starting from 48900 for butcher Chang'an Lumin

Abbkine column exkine Pro animal cell / tissue Total Protein Extraction Kit
随机推荐
初中毕业生,选择中职学校也可以升入高等学府
MySQL inserts query results into other tables
[nk] Niuke monthly competition 51 f-average question
【北大青鸟昌平校区】职教与普教协调发展,今年的中考会容易吗?
C language -- 10 first knowledge of structure
Leetcode advanced path - the first unique character in a string
C language -- 4 first-time constant
Calculus review 1
Super detailed tutorial for installing mysql8 in centos7 (no pit!)
C language -- 3 variables for beginners
php伪协议实现命令执行详情
Business based precipitation component = & gt; manage-table
SQL第四练:字符串处理函数
C language ---9 first knowledge of macros and pointers
Before we learn about high-performance computing, let's take a look at its history
Detailed explanation of MySQL range query optimization scenario instances
Can I make up the exam if I fail the soft exam? Here comes the answer
Leetcode advanced road - 125 Validate palindrome string
JS anchor positioning can extend many functions
php的exec函数