Skip to content

feat: add php solutions to lc problem: No.0001 #896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 22, 2023
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
22 changes: 22 additions & 0 deletions solution/0000-0099/0001.Two Sum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,29 @@ proc twoSum(nums: seq[int], target: int): seq[int] =
tdx = nums.find(bal)
if idx != tdx:
return @[idx, tdx]
```

### **PHP**

```php
class Solution {

/**
* @param Integer[] $nums
* @param Integer $target
* @return Integer[]
*/
function twoSum($nums, $target) {
$len = count($nums);
for ($i = 0; $i < $len; $i++) {
for ($j = 1 + $i; $j < $len; $j++) {
if ($nums[$i] + $nums[$j] == $target) {
return [$i, $j];
}
}
}
}
}
```

### **...**
Expand Down
22 changes: 22 additions & 0 deletions solution/0000-0099/0001.Two Sum/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,29 @@ proc twoSum(nums: seq[int], target: int): seq[int] =
tdx = nums.find(bal)
if idx != tdx:
return @[idx, tdx]
```

### **PHP**

```php
class Solution {

/**
* @param Integer[] $nums
* @param Integer $target
* @return Integer[]
*/
function twoSum($nums, $target) {
$len = count($nums);
for ($i = 0; $i < $len; $i++) {
for ($j = 1 + $i; $j < $len; $j++) {
if ($nums[$i] + $nums[$j] == $target) {
return [$i, $j];
}
}
}
}
}
```

### **...**
Expand Down
18 changes: 18 additions & 0 deletions solution/0000-0099/0001.Two Sum/Solution.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Solution {

/**
* @param Integer[] $nums
* @param Integer $target
* @return Integer[]
*/
function twoSum($nums, $target) {
$len = count($nums);
for ($i = 0; $i < $len; $i++) {
for ($j = 1 + $i; $j < $len; $j++) {
if ($nums[$i] + $nums[$j] == $target) {
return [$i, $j];
}
}
}
}
}