Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions solution/0300-0399/0349.Intersection of Two Arrays/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,30 @@ func intersection(nums1 []int, nums2 []int) []int {
}
```

### **PHP**

```php
class Solution {
/**
* @param Integer[] $nums1
* @param Integer[] $nums2
* @return Integer[]
*/
function intersection($nums1, $nums2) {
$rs = [];
$set1 = array_values(array_unique($nums1));
$set2 = array_values(array_unique($nums2));
for ($i = 0; $i < count($set1); $i++) {
$hashmap[$set1[$i]] = 1;
}
for ($j = 0; $j < count($set2); $j++) {
if ($hashmap[$set2[$j]]) array_push($rs, $set2[$j]);
}
return $rs;
}
}
```

### **...**

```
Expand Down
24 changes: 24 additions & 0 deletions solution/0300-0399/0349.Intersection of Two Arrays/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,30 @@ func intersection(nums1 []int, nums2 []int) []int {
}
```

### **PHP**

```php
class Solution {
/**
* @param Integer[] $nums1
* @param Integer[] $nums2
* @return Integer[]
*/
function intersection($nums1, $nums2) {
$rs = [];
$set1 = array_values(array_unique($nums1));
$set2 = array_values(array_unique($nums2));
for ($i = 0; $i < count($set1); $i++) {
$hashmap[$set1[$i]] = 1;
}
for ($j = 0; $j < count($set2); $j++) {
if ($hashmap[$set2[$j]]) array_push($rs, $set2[$j]);
}
return $rs;
}
}
```

### **...**

```
Expand Down
19 changes: 19 additions & 0 deletions solution/0300-0399/0349.Intersection of Two Arrays/Solution.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Solution {
/**
* @param Integer[] $nums1
* @param Integer[] $nums2
* @return Integer[]
*/
function intersection($nums1, $nums2) {
$rs = [];
$set1 = array_values(array_unique($nums1));
$set2 = array_values(array_unique($nums2));
for ($i = 0; $i < count($set1); $i++) {
$hashmap[$set1[$i]] = 1;
}
for ($j = 0; $j < count($set2); $j++) {
if ($hashmap[$set2[$j]]) array_push($rs, $set2[$j]);
}
return $rs;
}
}