Skip to content

Commit 8cfd935

Browse files
Qiu-ITQiu-IT
authored andcommitted
feat:add php solutions to lc problem: No.0001
1 parent 561c6a7 commit 8cfd935

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

solution/0000-0099/0001.Two Sum/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,30 @@ pub fn soluation(nums: Vec<i32>, target: i32) -> Vec<i32> {
243243
}
244244
```
245245

246+
### **PHP**
247+
248+
```php
249+
class Solution {
250+
251+
/**
252+
* @param Integer[] $nums
253+
* @param Integer $target
254+
* @return Integer[]
255+
*/
256+
function twoSum($nums, $target) {
257+
$len = count($nums);
258+
for ($i=0; $i<$len; $i++) {
259+
for ($j=1+$i; $j<$len; $j++) {
260+
if($nums[$i]+$nums[$j]==$target)
261+
{
262+
return [$i,$j];
263+
}
264+
}
265+
}
266+
}
267+
}
268+
```
269+
246270
### **...**
247271

248272
```

solution/0000-0099/0001.Two Sum/README_EN.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,30 @@ pub fn soluation(nums: Vec<i32>, target: i32) -> Vec<i32> {
224224
}
225225
```
226226

227+
### **PHP**
228+
229+
```php
230+
class Solution {
231+
232+
/**
233+
* @param Integer[] $nums
234+
* @param Integer $target
235+
* @return Integer[]
236+
*/
237+
function twoSum($nums, $target) {
238+
$len = count($nums);
239+
for ($i=0; $i<$len; $i++) {
240+
for ($j=1+$i; $j<$len; $j++) {
241+
if($nums[$i]+$nums[$j]==$target)
242+
{
243+
return [$i,$j];
244+
}
245+
}
246+
}
247+
}
248+
}
249+
```
250+
227251
### **...**
228252

229253
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
3+
/**
4+
* @param Integer[] $nums
5+
* @param Integer $target
6+
* @return Integer[]
7+
*/
8+
function twoSum($nums, $target) {
9+
$len = count($nums);
10+
for ($i=0; $i<$len; $i++) {
11+
for ($j=1+$i; $j<$len; $j++) {
12+
if($nums[$i]+$nums[$j]==$target)
13+
{
14+
return [$i,$j];
15+
}
16+
}
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)