Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0ea30cc

Browse files
committed
349-intersection-of-two-arrays.md Separated Chinese solutions from English solutions.
1 parent86aead2 commit0ea30cc

File tree

3 files changed

+30
-97
lines changed

3 files changed

+30
-97
lines changed

‎en/1-1000/349-intersection-of-two-arrays.md

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
#349. Intersection of Two Arrays - Best Practices of LeetCode Solutions
2-
LeetCode link:[349. Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays),
3-
[349. 两个数组的交集](https://leetcode.cn/problems/intersection-of-two-arrays)
2+
LeetCode link:[349. Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays), difficulty:**Easy**.
43

5-
[中文题解](#中文题解)
6-
7-
##LeetCode problem description
4+
##LeetCode description of "349. Intersection of Two Arrays"
85
Given two integer arrays`nums1` and`nums2`, return_an array of their**intersection**_.
96
Each element in the result must be**unique** and you may return the result in**any order**.
107

11-
Difficulty:**Easy**
8+
>Array Intersection: The intersection of two arrays is defined as the set of elements that are present in both arrays.
129
1310
###[Example 1]
1411
**Input**:`nums1 = [1,2,2,1], nums2 = [2,2]`
@@ -25,15 +22,13 @@ Difficulty: **Easy**
2522
-`0 <= nums1[i], nums2[i] <= 1000`
2623

2724
##Intuition
28-
[中文题解](#中文题解)
29-
3025
1. Convert one of the arrays to a`set`. The elements are unique in a`set`.
3126
2. When traversing the other array, if the an element is found to already exist in the`set`, it means that the element belongs to the intersection, and the element should be added to the`results`.
3227
3. The`results` is also of`set` type because duplicate removal is required.
3328

3429
##Complexity
35-
* Time:`O(n)`.
36-
* Space:`O(n)`.
30+
* Time:`O(N)`.
31+
* Space:`O(N)`.
3732

3833
##Java
3934
```java
@@ -191,24 +186,3 @@ end
191186
```
192187
// Welcome to create a PR to complete the code of this language, thanks!
193188
```
194-
195-
##问题描述
196-
给定两个数组`nums1``nums2` ,返回_它们的**交集**_ 。输出结果中的每个元素一定是**唯一** 的。我们可以**不考虑输出结果的顺序**
197-
198-
难度:**容易**
199-
200-
###[示例 1]
201-
**输入**:`nums1 = [1,2,2,1], nums2 = [2,2]`
202-
203-
**输出**:`[2]`
204-
205-
###[示例 2]
206-
**输入**:`nums1 = [4,9,5], nums2 = [9,4,9,8,4]`
207-
208-
**输出**:`[9,4]` 或者`[4,9]`
209-
210-
#中文题解
211-
##思路
212-
1. 把其中一个数组转为`set`,数据结构`set`的特点是元素不重复。
213-
2. 遍历另一个数组时,如果发现当前元素已经存在于`set`中,则说明该元素属于交集,将该元素加入结果集中。
214-
3. 结果集也采用`set`类型,因为需要去重。

‎en/3001-4000/unorganized.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,6 @@ Add a table to show the differences between A-Start and breadth-first search
203203

204204
##other finished problems
205205
-https://leetcode.com/problems/k-closest-points-to-origin/
206+
-https://leetcode.com/problems/find-special-substring-of-length-k/
207+
-https://leetcode.cn/problems/eat-pizzas/
206208
-

‎zh/1-1000/349-intersection-of-two-arrays.md

Lines changed: 23 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
1-
#349. Intersection of Two Arrays - Best Practices of LeetCode Solutions
2-
LeetCode link:[349. Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays),
3-
[349. 两个数组的交集](https://leetcode.cn/problems/intersection-of-two-arrays)
1+
#349. 两个数组的交集 - 力扣题解最佳实践
2+
力扣链接:[349. 两个数组的交集](https://leetcode.cn/problems/intersection-of-two-arrays) ,难度:**简单**
43

5-
[中文题解](#中文题解)
4+
##力扣“349. 两个数组的交集”问题描述
5+
给定两个数组`nums1``nums2` ,返回_它们的**交集**_ 。输出结果中的每个元素一定是**唯一** 的。我们可以**不考虑输出结果的顺序**
66

7-
##LeetCode problem description
8-
Given two integer arrays`nums1` and`nums2`, return_an array of their**intersection**_.
9-
Each element in the result must be**unique** and you may return the result in**any order**.
7+
>数组的交集: The intersection of two arrays is defined as the set of elements that are present in both arrays.
108
11-
Difficulty:**Easy**
9+
###[示例 1]
10+
11+
**输入**:`nums1 = [1,2,2,1], nums2 = [2,2]`
12+
13+
**输出**:`[2]`
1214

13-
###[Example 1]
14-
**Input**:`nums1 = [1,2,2,1], nums2 = [2,2]`
15+
###[示例 2]
1516

16-
**Output**:`[2]`
17+
**输入**:`nums1 = [4,9,5], nums2 = [9,4,9,8,4]`
1718

18-
###[Example 2]
19-
**Input**:`nums1 = [4,9,5], nums2 = [9,4,9,8,4]`
19+
**输出**:`[9,4]`
2020

21-
**Output**:`[9,4]` or`[4,9]`
21+
**解释**:`[4,9] 也是可通过的`
2222

23-
###[Constraints]
23+
###[约束]
2424
-`1 <= nums1.length, nums2.length <= 1000`
2525
-`0 <= nums1[i], nums2[i] <= 1000`
2626

27-
##Intuition
28-
[中文题解](#中文题解)
29-
30-
1. Convert one of the arrays to a`set`. The elements are unique in a`set`.
31-
2. When traversing the other array, if the an element is found to already exist in the`set`, it means that the element belongs to the intersection, and the element should be added to the`results`.
32-
3. The`results` is also of`set` type because duplicate removal is required.
27+
##思路
28+
1. 把其中一个数组转为`set`,数据结构`set`的特点是元素不重复。
29+
2. 遍历另一个数组时,如果发现当前元素已经存在于`set`中,则说明该元素属于交集,将该元素加入结果集中。
30+
3. 结果集也采用`set`类型,因为需要去重。
3331

34-
##Complexity
35-
*Time:`O(n)`.
36-
*Space:`O(n)`.
32+
##复杂度
33+
*时间:`O(N)`
34+
*空间:`O(N)`
3735

3836
##Java
3937
```java
@@ -167,48 +165,7 @@ def intersection(nums1, nums2)
167165
end
168166
```
169167

170-
##C
171-
```c
172-
// Welcome to create a PR to complete the code of this language, thanks!
173-
```
174-
175-
##Kotlin
176-
```kotlin
177-
// Welcome to create a PR to complete the code of this language, thanks!
178-
```
179-
180-
##Swift
181-
```swift
182-
// Welcome to create a PR to complete the code of this language, thanks!
183-
```
184-
185-
##Rust
186-
```rust
187-
// Welcome to create a PR to complete the code of this language, thanks!
188-
```
189-
190-
##Other languages
168+
##C, Kotlin, Swift, Rust or other languages
191169
```
192170
// Welcome to create a PR to complete the code of this language, thanks!
193171
```
194-
195-
##问题描述
196-
给定两个数组`nums1``nums2` ,返回_它们的**交集**_ 。输出结果中的每个元素一定是**唯一** 的。我们可以**不考虑输出结果的顺序**
197-
198-
难度:**容易**
199-
200-
###[示例 1]
201-
**输入**:`nums1 = [1,2,2,1], nums2 = [2,2]`
202-
203-
**输出**:`[2]`
204-
205-
###[示例 2]
206-
**输入**:`nums1 = [4,9,5], nums2 = [9,4,9,8,4]`
207-
208-
**输出**:`[9,4]` 或者`[4,9]`
209-
210-
#中文题解
211-
##思路
212-
1. 把其中一个数组转为`set`,数据结构`set`的特点是元素不重复。
213-
2. 遍历另一个数组时,如果发现当前元素已经存在于`set`中,则说明该元素属于交集,将该元素加入结果集中。
214-
3. 结果集也采用`set`类型,因为需要去重。

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp