File tree Expand file tree Collapse file tree 3 files changed +67
-0
lines changed
solution/0300-0399/0349.Intersection of Two Arrays Expand file tree Collapse file tree 3 files changed +67
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,30 @@ func intersection(nums1 []int, nums2 []int) []int {
148
148
}
149
149
```
150
150
151
+ ### ** PHP**
152
+
153
+ ``` php
154
+ class Solution {
155
+ /**
156
+ * @param Integer[] $nums1
157
+ * @param Integer[] $nums2
158
+ * @return Integer[]
159
+ */
160
+ function intersection($nums1, $nums2) {
161
+ $rs = [];
162
+ $set1 = array_values(array_unique($nums1));
163
+ $set2 = array_values(array_unique($nums2));
164
+ for ($i = 0; $i < count($set1); $i++) {
165
+ $hashmap[$set1[$i]] = 1;
166
+ }
167
+ for ($j = 0; $j < count($set2); $j++) {
168
+ if ($hashmap[$set2[$j]]) array_push($rs, $set2[$j]);
169
+ }
170
+ return $rs;
171
+ }
172
+ }
173
+ ```
174
+
151
175
### ** ...**
152
176
153
177
```
Original file line number Diff line number Diff line change @@ -136,6 +136,30 @@ func intersection(nums1 []int, nums2 []int) []int {
136
136
}
137
137
```
138
138
139
+ ### ** PHP**
140
+
141
+ ``` php
142
+ class Solution {
143
+ /**
144
+ * @param Integer[] $nums1
145
+ * @param Integer[] $nums2
146
+ * @return Integer[]
147
+ */
148
+ function intersection($nums1, $nums2) {
149
+ $rs = [];
150
+ $set1 = array_values(array_unique($nums1));
151
+ $set2 = array_values(array_unique($nums2));
152
+ for ($i = 0; $i < count($set1); $i++) {
153
+ $hashmap[$set1[$i]] = 1;
154
+ }
155
+ for ($j = 0; $j < count($set2); $j++) {
156
+ if ($hashmap[$set2[$j]]) array_push($rs, $set2[$j]);
157
+ }
158
+ return $rs;
159
+ }
160
+ }
161
+ ```
162
+
139
163
### ** ...**
140
164
141
165
```
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ /**
3
+ * @param Integer[] $nums1
4
+ * @param Integer[] $nums2
5
+ * @return Integer[]
6
+ */
7
+ function intersection ($nums1 , $nums2 ) {
8
+ $rs = [];
9
+ $set1 = array_values (array_unique ($nums1 ));
10
+ $set2 = array_values (array_unique ($nums2 ));
11
+ for ($i = 0 ; $i < count ($set1 ); $i ++ ) {
12
+ $hashmap [$set1 [$i ]] = 1 ;
13
+ }
14
+ for ($j = 0 ; $j < count ($set2 ); $j ++ ) {
15
+ if ($hashmap [$set2 [$j ]]) array_push ($rs , $set2 [$j ]);
16
+ }
17
+ return $rs ;
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments