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
25 changes: 25 additions & 0 deletions solution/0300-0399/0350.Intersection of Two Arrays II/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,31 @@ impl Solution {
}
```

### **PHP**

```php
class Solution {
/**
* @param Integer[] $nums1
* @param Integer[] $nums2
* @return Integer[]
*/
function intersect($nums1, $nums2) {
$rs = [];
for ($i = 0; $i < count($nums1); $i++) {
$hashtable[$nums1[$i]] += 1;
}
for ($j = 0; $j < count($nums2); $j++) {
if (isset($hashtable[$nums2[$j]]) && $hashtable[$nums2[$j]] > 0) {
array_push($rs, $nums2[$j]);
$hashtable[$nums2[$j]] -= 1;
}
}
return $rs;
}
}
```

### **...**

```
Expand Down
25 changes: 25 additions & 0 deletions solution/0300-0399/0350.Intersection of Two Arrays II/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,31 @@ impl Solution {
}
```

### **PHP**

```php
class Solution {
/**
* @param Integer[] $nums1
* @param Integer[] $nums2
* @return Integer[]
*/
function intersect($nums1, $nums2) {
$rs = [];
for ($i = 0; $i < count($nums1); $i++) {
$hashtable[$nums1[$i]] += 1;
}
for ($j = 0; $j < count($nums2); $j++) {
if (isset($hashtable[$nums2[$j]]) && $hashtable[$nums2[$j]] > 0) {
array_push($rs, $nums2[$j]);
$hashtable[$nums2[$j]] -= 1;
}
}
return $rs;
}
}
```

### **...**

```
Expand Down
20 changes: 20 additions & 0 deletions solution/0300-0399/0350.Intersection of Two Arrays II/Solution.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Solution {
/**
* @param Integer[] $nums1
* @param Integer[] $nums2
* @return Integer[]
*/
function intersect($nums1, $nums2) {
$rs = [];
for ($i = 0; $i < count($nums1); $i++) {
$hashtable[$nums1[$i]] += 1;
}
for ($j = 0; $j < count($nums2); $j++) {
if (isset($hashtable[$nums2[$j]]) && $hashtable[$nums2[$j]] > 0) {
array_push($rs, $nums2[$j]);
$hashtable[$nums2[$j]] -= 1;
}
}
return $rs;
}
}