Skip to content

Commit 96d78ae

Browse files
authoredMar 2, 2023
feat: add php solution to lc problem: No.0088 (#903)
No.0088.Merge Sorted Array
1 parent 5d31bb9 commit 96d78ae

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed
 

‎solution/0000-0099/0088.Merge Sorted Array/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,29 @@ impl Solution {
196196
}
197197
```
198198

199+
### **PHP**
200+
201+
```php
202+
class Solution {
203+
/**
204+
* @param Integer[] $nums1
205+
* @param Integer $m
206+
* @param Integer[] $nums2
207+
* @param Integer $n
208+
* @return NULL
209+
*/
210+
function merge(&$nums1, $m, $nums2, $n) {
211+
while (count($nums1) > $m) {
212+
array_pop($nums1);
213+
}
214+
for ($i = 0; $i < $n; $i++) {
215+
array_push($nums1, $nums2[$i]);
216+
}
217+
asort($nums1);
218+
}
219+
}
220+
```
221+
199222
### **...**
200223

201224
```

‎solution/0000-0099/0088.Merge Sorted Array/README_EN.md

+23
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,29 @@ impl Solution {
183183
}
184184
```
185185

186+
### **PHP**
187+
188+
```php
189+
class Solution {
190+
/**
191+
* @param Integer[] $nums1
192+
* @param Integer $m
193+
* @param Integer[] $nums2
194+
* @param Integer $n
195+
* @return NULL
196+
*/
197+
function merge(&$nums1, $m, $nums2, $n) {
198+
while (count($nums1) > $m) {
199+
array_pop($nums1);
200+
}
201+
for ($i = 0; $i < $n; $i++) {
202+
array_push($nums1, $nums2[$i]);
203+
}
204+
asort($nums1);
205+
}
206+
}
207+
```
208+
186209
### **...**
187210

188211
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution {
2+
/**
3+
* @param Integer[] $nums1
4+
* @param Integer $m
5+
* @param Integer[] $nums2
6+
* @param Integer $n
7+
* @return NULL
8+
*/
9+
function merge(&$nums1, $m, $nums2, $n) {
10+
while (count($nums1) > $m) {
11+
array_pop($nums1);
12+
}
13+
for ($i = 0; $i < $n; $i++) {
14+
array_push($nums1, $nums2[$i]);
15+
}
16+
asort($nums1);
17+
}
18+
}

0 commit comments

Comments
 (0)